1、设置用户名密码
首次登录后修改密码如下:
如果密码设置太过简单会报以下错误
mysql修改密码Your password does not satisfy the current policy requirements
出现这个问题的原因是:密码过于简单。刚安装的mysql的密码默认强度是最高的,如果想要设置简单的密码就要修改validate_password_policy的值,
validate_password_policy有以下取值:
Policy | Tests Performed |
---|---|
0 or LOW
|
Length |
1 or MEDIUM
|
Length; numeric, lowercase/uppercase, and special characters |
2 or STRONG
|
Length; numeric, lowercase/uppercase, and special characters; dictionary file |
默认是1,因此我们就设置中增加大小写和特殊字符即可。
2、配置允许外网连接
2.登录数据库
mysql -u root -p
#输入密码
3.转到系统数据库
mysql> use mysql;
4.查询host
mysql> select user,host from user;
5.创建host
#如果没有"%"这个host值,就执行下面这两句:
mysql> update user set host='%' where user='root';
mysql> flush privileges;
6.授权用户
#任意主机以用户root和密码mypwd连接到mysql服务器
mysql> grant all privileges on *.* to 'root'@'%' identified by 'mypwd' with grant option;
#IP为192.168.1.100的主机以用户myuser和密码mypwd连接到mysql服务器
mysql> grant all privileges on *.* to 'myuser'@'192.168.1.100' identified by 'mypwd' with grant option;
7.刷新权限
mysql> flush privileges;
操作截图如下:
忘记密码参考:
参考: