mysql5.7 忘记root密码后,如何找回密码?
生活随笔
收集整理的這篇文章主要介紹了
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 5 Server version: 5.7.27 MySQL Community Server (GPL)Copyright (c) 2000, 2019, 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>修改密碼
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密码后,如何找回密码?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 科技昨夜今晨 1110:华为智选车首款轿
- 下一篇: 泰国与丰田合作发展电动汽车业务,计划试行