windows下忘記mysql超級管理員root密碼的解決辦法(也適用於wamp)


1、停止mysql服務。

2,在CMD命令行窗口,進入MYSQL安裝目錄 比如 d:mysql20080505in

 

3,進入mysql安全模式,即當mysql起來后,不用輸入密碼就能進入數據庫。
命令為: mysqld -nt --skip-grant-tables

 
***************************************
4,重新打開一個CMD命令行窗口,輸入mysql -uroot -p,使用空密碼的方式登錄MySQL(不用輸入密碼,直接按回車)

 

5,輸入use  mysql。

如果報錯  You must reset your password using ALTER USER statement before executing this statement.

step 1: SET PASSWORD = PASSWORD('your new password');

step 2: ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;

step 3: flush privileges;

如果沒有報錯,則要進行步驟 6/7/8。

6、輸入以下命令開始修改root用戶的密碼(注意:命令中mysql.user中間有個“點”)
  mysql> update mysql.user set password=PASSWORD("新密碼") where User="root";

 #修改密碼報錯

ERROR 1054 (42S22): Unknown column 'password' in 'field list' mysql> update mysql.user set authentication_string=password('*******') where user='*******'; #修改密碼成功 Query OK, 1 row affected, 1 warning (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 1

6,刷新權限表
mysql> flush privileges;

 

7,退出
mysql> quit 

 

 或者:

解決Your password has expired. To log in you must change it using a client that supports expired passwords辦法

打開 命令行

 
  1. /usr/local/mysql/bin/mysqladmin -u root -p password  
/usr/local/mysql/bin/mysqladmin -u root -p password


提示輸入按照后的那個密碼

輸入完成后 提示輸入新的密碼

 
  1. Enter password:   
  2. New password:   

Confirm new password: 

完成


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM