提示:access denied for user 'root'@'localhost' using password yes/no
原來都好好的,今天開機上來提示上面的這個錯誤,重啟 MySQL 還是不可以。
注意我這里的環境是 WINDOWS-XP 系統,LINUX 系統下的操作沒有驗證過,情況不清楚。
1. 管理員登陸系統,停止 MySQL 服務或者結束 MySQL 進程。
2. 啟動 WINDOWS 的命令行窗口(即通常的 DOS 窗口:運行cmd),切換到你的 “MySQL/bin” 目錄下。 例如我的是 “D:/Program Files/MySQL/MySQL Server 5.2/bin”,然后執行下面的粗體的命令:(注意你的 “my.ini” 位置)
Microsoft Windows XP [版本 5.1.2600] (C) 版權所有 1985-2001 Microsoft Corp.
C:/Documents and Settings/Administrator>cd D:/Program Files/MySQL/MySQL Server 5.2/bin
C:/Documents and Settings/Administrator>d:
D:/Program Files/MySQL/MySQL Server 5.2/bin>mysqld --defaults-file="D:/Program Files/MySQL/MySQL Server 5.2/my.ini" --console --skip-grant-tables
100608 9:04:12 InnoDB: Started; log sequence number 0 46409 100608 9:04:12 [Note] mysqld: ready for connections. Version: '5.2.0-falcon-alpha-community' socket: '' port: 3306 MySQL Community Server (GPL) 100608 9:06:57 [Warning] Found invalid password for user: 'root@localhost'; Ign oring user
Microsoft Windows XP [版本 5.1.2600] (C) 版權所有 1985-2001 Microsoft Corp.
C:/Documents and Settings/Administrator>cd D:/Program Files/MySQL/MySQL Server 5.2/bin
C:/Documents and Settings/Administrator>d:
D:/Program Files/MySQL/MySQL Server 5.2/bin>mysql -u root mysql Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 1 Server version: 5.2.0-falcon-alpha-community MySQL Community Server (GPL)
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
然后,就是重新設置密碼了!
mysql> UPDATE user SET Password=PASSWORD('root') where USER='root'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0
4. 好了到此步,可以關閉第一個 DOS 窗口了(關閉服務)。打開系統服務控制窗口(控制面板--管理工具--服務),啟動 MySQL 服務。
5. 在剩下的第二個 DOS 窗口中,用新的 ROOT 密碼連接 MySQL。
D:/Program Files/MySQL/MySQL Server 5.2/bin>mysql -u root -p Enter password: **** Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 1 Server version: 5.2.0-falcon-alpha-community-nt MySQL Community Server (GPL)
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.