(2)使用--skip-grant-tables重启MySQL [root@localhost mysql]# ./bin/mysqld_safe --skip-grant-tables --user=test & [root@localhost mysql]# Starting mysqld daemon with database from /home/test/mysql/data --skip-grant-tables的意思是启动MySQL的时候不检测权限表认证
(3)再次连接MySQL修改ROOT密码 [root@localhost mysql]# mysql -uroot mysql> set password = password('123123') ERROR 1290(HY000):The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement mysql> update user set password=password('123123') where user='root' and host='localhost'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 使用--skip-grant-tables启动MySQL不能使用set password修改密码直接update更改user表即可 mysql> flush privileges; Query OK, 0 row affected (0.00 sec)
(4)重新用ROOT登录MySQL [root@localhost mysql]# mysql -uroot -p123123 mysql>