跳至主要內容

MySQL ERROR 1045 (28000)

[Problem]:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


[Situation]:

將舊資料庫檔案匯入後,登入 MySQL 時出現錯誤

原因是root 密碼被換掉了


[Solution]:

1. 先將 MySQL 關閉:

service mysqld stop 

2. 使用安全模式進入 MySQL 

 /usr/bin/mysqld_safe --skip-grant-tables & 

3.修改密碼

mysql

use mysql; 

update user set password=password('yournewpasswordhere') where user='root'; 

flush privileges; 

exit; 

4. 重啟 MySQL 

 service mysqld start 

5.  密碼更改完成


[Reference]:

https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html 

https://blog.51cto.com/pppcode/510972 

https://stackoverflow.com/questions/1708409/how-to-start-mysql-with-skip-grant-tables 

https://help.ubuntu.com/community/MysqlPasswordReset 

http://mustgeorge.blogspot.com/2011/11/mysql-error-1045-28000-using-password.html 

https://blog.csdn.net/zzq900503/article/details/14163769

留言

此網誌的熱門文章

意外的起頭

去年暑假開始 意~外的接觸了這個世界 意~外的開始了這個學習的旅程 意~外的開始總是說不清的XDDD 先謝謝一路教我的DC跟一起學習的MK 還有不厭其煩的被我問問題的H-很愛嗆我... 以及途中的SHS跟K及PH 還有很長的路要走 未來這一年挑戰多多啊~~ 歌,未央