MySQL重置root密码

1.打开配置文件/etc/mysql/mysql.conf/mysql.cnf,在mysqld下添加一行skip-grant-tables

[mysqld]
#...
skip-grant-tables
#...

2.重启mysql
service mysql restart
3.登陆mysql

mysql -uroot -p
mysql> use mysql;
update user set authentication_string=password('newpassword') where user='root';

4.修改 /etc/mysql/mysql.conf/mysql.cnf 文件,去掉skip-grant-tables
5.重启mysql
service mysql restart

点赞