命令: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 restart3.进入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 requirements2.设置密码永久不会改变
@H_403_6@alter user 'root'@localhost password expire never;3.刷新数据库
@H_403_6@flush privileges;大功告成!
原文链接:https://www.f2er.com/centos/379697.html