#1045 無法登錄 MySQL 服務器
出現這些問題都可以用此方法
- 在本地無法連接服務器
- phpMyAdmin無法登錄
- 修改root密碼

1.停止mysql資料庫
/etc/init.d/mysqld stop
(或者直接 kill -9 [PID] 殺行程!)
2.執行如下命令
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
3.使用root登錄mysql資料庫
mysql -u root mysql
4.更新root密碼
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
最新版MySQL請采用如下SQL:
mysql> UPDATE user SET authentication_string=PASSWORD('newpassword') where USER='root';
5.重繪權限
mysql> FLUSH PRIVILEGES;
6.退出mysql
mysql> quit
7.重啟mysql
/etc/init.d/mysqld restart
8.使用root用戶重新登錄mysql
mysql -uroot -p Enter password: <輸入新設的密碼newpassword>

轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/157503.html
標籤:其他
