修改 vim /etc/my.cnf 加上一句:skip-grant-tables
1.保存并且退出。重新启动mysqld
service mysqld restart
2.登录并修改MySQL的root密码
mysql
use mysql;
sql: update user set authentication_string=password(‘new password’) where user=’root;
3.执行 flush privileges;
4.退出mysql。
5.删除 skip-grant-tables
6.重启mysql