1.vim /etc/my.cnf
skip-grant-tables #取消此行的注釋
2.重啟mysql
systemctl restart mysqld
3.mysql 登陸mysql
mysql> use mysql;
mysql> UPDATE user SET Password = password ( '123456' ) WHERE User = 'root' ;
mysql> flush privileges ;
mysql> quit
4.恢復配置文件my.cnf
vim /etc/my.cnf
[mysqld]
skip-grant-tables ##去掉此行,繼續校驗權限表,
5.重啟mysql
systemctl restart mysqld