失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > mysql5.7 忘记root密码后 如何找回密码?

mysql5.7 忘记root密码后 如何找回密码?

时间:2019-03-14 18:27:48

相关推荐

mysql5.7 忘记root密码后 如何找回密码?

前言

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密码后 如何找回密码?》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。