CentOS修改MySQL5.7.16用户密码

前端之家收集整理的这篇文章主要介绍了CentOS修改MySQL5.7.16用户密码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.修改MysqL配置文件my.conf;

命令:vim /etc/my.conf;在MysqLd下增加一行

内容

@H_403_6@datadir=/var/lib/MysqL socket=/var/lib/MysqL/MysqL.sock

修改后的:

@H_403_6@datadir=/var/lib/MysqL socket=/var/lib/MysqL/MysqL.sock skip-grant-tables (新增的)

2.重启MysqL

命令:

@H_403_6@service MysqLd restart

3.进入MysqL

命令:

@H_403_6@MysqL; use MysqL; update user set authentication_string=password('a') where user='root'; flush privileges ; exit

执行的结果是这样的:

4.去掉1中增加的那一行命令;

5.重启MysqL,命令同2;

6.进入MysqL

命令:

@H_403_6@MysqL -uroot -p

回车输入密码,即可见如下图:

登录后报错:

@H_403_6@You must reset your password using ALTER USER statement before executing

解决办法:

1.设置密码

@H_403_6@SET PASSWORD = PASSWORD(‘your new password‘);

这里密码必须复杂,否则会报错

@H_403_6@Your password does not satisfy the current policy requirements

2.设置密码永久不会改变

@H_403_6@alter user 'root'@localhost password expire never;

3.刷新数据库

@H_403_6@flush privileges;

大功告成!

原文链接:https://www.f2er.com/centos/379697.html

猜你在找的CentOS相关文章