解决在CentOS 7上重装MySQL 5.7.10后root账户无法登陆

前端之家收集整理的这篇文章主要介绍了解决在CentOS 7上重装MySQL 5.7.10后root账户无法登陆前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
1. Stop MysqL: systemctl stop MysqLd 2. Set the MysqL environment option systemctl set-environment MysqLD_OPTS="--skip-grant-tables" 3.Start MysqL usig the options you just set systemctl start MysqLd 4. Login as root MysqL -u root 5.Update the root user password with these MysqL commands MysqL>UPDATE MysqL.SET authentication_string = PASSWORD('MyNewPassword') ->WHEREUser 'root'AND Host 'localhost'; FLUSH PRIVILEGES quit 6. Stop MysqL systemctl stop MysqLd 7. Unset the MysqL envitroment  so it starts normally next time systemctl unset-environment MysqLD_OPTS 8. MysqL normally MysqLd Try to login using your new password MysqL u root p
----------------------------------------------------------
[root@localhost ~]# MysqL -uroot Welcome to the MysqL monitor. Commands end with ; or \g. Your MysqL connection id is 3 Server version: 5.7.16 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> UPDATE MysqL.user SET authentication_string = PASSWORD('XXXXXX') WHERE User = 'root' AND Host = 'localhost'; Query OK,1 row affected,1 warning (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 1 MysqL> FLUSH PRIVILEGES; Query OK,0 rows affected (0.01 sec) MysqL> quit Bye [root@localhost ~]# systemctl stop MysqLd [root@localhost ~]# systemctl unset-environment MysqLD_OPTS [root@localhost ~]# systemctl start MysqLd [root@localhost ~]# MysqL -uroot ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@localhost ~]# MysqL -uroot -pXXXXXX MysqL: [Warning] Using a password on the command line interface can be insecure. Welcome to the MysqL monitor. Commands end with ; or \g. Your MysqL connection id is 3 Server version: 5.7.16 Copyright (c) 2000,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> show databases; ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. MysqL> set global validate_password_policy=0; Query OK,0 rows affected,1 warning (0.00 sec) MysqL> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('XXXXXX'); Query OK,1 warning (0.00 sec) MysqL> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | MysqL | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec)

猜你在找的CentOS相关文章