1、vi /etc/my.cnf
加入
[mysqld]
skip-grant-tables ##追加此行,跳过权限表,
2.重启mysql
service mysql restart
3.mysql 登陆mysql
mysql> use mysql;
mysql> update mysql.user set authentication_string=password(‘123456’) where user=‘root’ and Host = ‘localhost’;
mysql> flush privileges ;
mysql> quit
4.恢复配置文件my.cnf
vim /etc/my.cnf
[mysqld]
skip-grant-tables ##去掉此行,继续校验权限表,
5.重启mysql
service mysql restart