1. vim /etc/my.cnf
在 [ mysqld] 下面添加一行:
skip-grant-tables 保存退出
2.killall mysqld
命令行 mysql 进入
update mysql.user set authentication_string=password("新密码") where user="root" and host="localhost";
3. flush privileges;
4.exit退出,killall mysqld 。 vim /etc/my.cnf 去掉skip-grant-tables 这行,重启。ok