1. service MysqLd stop
2. vi /etc/my.cnf
3.在[MysqLd]片段中开始新增skip-grant-tables,保存退出vi
4.service MysqLd start
7.MysqL>update user set password=PASSWORD(’111111’) where user=’root’;
如果找不到password字段,是因为MysqL5.7版本password字段改成了authentication_string,用以下语句即可
MysqL>update user set authentication_string=password('111111') where user='root' ;
7.MysqL>flush privileges;
8.MysqL>quit;
9.vi /etc/my.cnf,删除skip-grant-tables,保存退出vi
10.service MysqLd start
11.MysqL -u root -p,此时输入密码即可。
原文链接:https://www.f2er.com/centos/378863.html