本文介紹了MySQL 錯誤::“用戶 'root'@'localhost' 的訪問被拒絕"的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
考慮:
./mysqladmin -u root -p** '_redacted_'
輸出(包括輸入密碼):
Output (including typing the password):
輸入密碼:
mysqladmin: 在 'localhost' 連接到服務(wù)器失敗錯誤:
'用戶'root'@'localhost'的訪問被拒絕(使用密碼:YES)'
mysqladmin: connect to server at 'localhost' failed error:
'Access denied for user 'root'@'localhost' (using password: YES)'
我該如何解決這個問題?
How can I fix this?
推薦答案
- 打開并編輯
/etc/my.cnf
或/etc/mysql/my.cnf
,具體取決于您的發(fā)行版. - 在
[mysqld]
下添加 - 重啟 MySQL
- 您現(xiàn)在應(yīng)該可以使用以下命令登錄 MySQL
mysql -u root -p
- 運行
mysql>刷新權(quán)限;
- 通過
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword'設(shè)置新密碼;
- 返回/etc/my.cnf 并remove/commentskip-grant-tables
- 重啟 MySQL
- 現(xiàn)在您可以使用新密碼登錄
mysql -u root -p
skip-grant-tables
- Open and edit
/etc/my.cnf
or/etc/mysql/my.cnf
, depending on your distribution. - Add
skip-grant-tables
under[mysqld]
- Restart MySQL
- You should be able to log in to MySQL now using the below command
mysql -u root -p
- Run
mysql> flush privileges;
- Set new password by
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';
- Go back to /etc/my.cnf and remove/comment skip-grant-tables
- Restart MySQL
- Now you will be able to login with the new password
mysql -u root -p
這篇關(guān)于MySQL 錯誤::“用戶 'root'@'localhost' 的訪問被拒絕"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!