MySQL 5.7.11 重置root密码
1.修改/etc/my.conf,添加参数skip-grant-tables 2.重启mysql service mysqld stop service mysqld start 3.用root 直接登录 [root@bogon ~]# mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.11 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> 4.修改密码 mysql> alter user 'root'@'localhost' identified by 'newpassword'; ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement mysql> 这种方式不好使,换一种方式: mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> update user set authentication_string=PASSWORD('newpassword') where User='root'; Query OK, 1 row affected, 1 warning (0.07 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql> 5.将/ect/my.conf 修改回来,重启mysql 测试新密码 [root@bogon ~]# service mysqld stop Stopping mysqld: [ OK ] [root@bogon ~]# service mysqld start Starting mysqld: [ OK ] [root@bogon ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.11 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> 修改完成