在mysql的配置文件中mysqld下加上skip-grant-table然后重启myql.用mysql进入后重新修改密码。
use mysql;
UPDATE user SET authentication_string = password (‘xxxx’) WHERE User = ‘root’;
flush privileges;
如果遇到以下错误
The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
解决:执行一次flush privileges;再重复命令。