MySQL啓動參數中有個是 --skip-grant-tables,叫做跳過授權表
1、停止mysqld服務
2、vim /etc/my.cnf
[mysqld]
skip-grant-tables
3、重啓mysql
4、進入mysql命令行
mysql>use mysql
mysql>update user set password=password('newpassword') where user='root';
mysql>flush privileges;
mysql>exit
5、去掉剛在my.cnf中增加的一行
#skip-grant-tables