您好,登錄后才能下訂單哦!
這篇文章主要介紹了mysql忘記root密碼怎么辦,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
1.關閉mysql 服務
點擊(此處)折疊或打開
net stop mysql57
2.執行mysqld
- 打開cmd窗口,切換至mysql安裝目錄
點擊(此處)折疊或打開
cd C:\Program Files\MySQL\MySQL Server 5.7\bin
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --skip-grant-tables
3.新開啟cmd,登錄root
-不用輸入password,直接回車
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uroot -p
Enter password:
4.修改root密碼
點擊(此處)折疊或打開
mysql> use mysql;
Database changed
mysql> update mysql.user set authentication_string=password('root') where user='root' ;
Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
5.使用新密碼登錄root
點擊(此處)折疊或打開
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uroot -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.19 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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 database;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'datab
ase' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| fortress |
| mysql |
| performance_schema |
| python |
| stuman |
| stuman2 |
| sys |
| www |
+--------------------+
9 rows in set (0.00 sec)
感謝你能夠認真閱讀完這篇文章,希望小編分享的“mysql忘記root密碼怎么辦”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。