前言
mysql 5.7.27忘记root密码操作步骤
关闭mysql
带参数--skip-grant-tables
启动mysql
mysqld --user=mysql --skip-grant-tables --skip-networking &
登录mysql
mysql -uroot----------------------------------------Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 5Server version: 5.7.27 MySQL Community Server (GPL)Copyright (c) 2000, , Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
修改密码
mysql> update mysql.user t set t.authentication_string=password("root") where t.user='root' and t.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.00 sec)
退出
mysql> quit----------------------------------------Bye
(不重启mysql的情况下,)再次登录,并设置密码
mysql -uroot -prootmysql> set password=password('root');----------------------------------------Query OK, 0 rows affected, 1 warning (0.00 sec)
关闭mysql并正常启动。至此root密码修改完成。
如果觉得《mysql5.7 忘记root密码后 如何找回密码?》对你有帮助,请点赞、收藏,并留下你的观点哦!