[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
留言
發佈留言