1. 程式人生 > >linux--解決登陸mysql資料庫出現 “Access denied for user 'root'@'localhost' (using password: YES)”的問題

linux--解決登陸mysql資料庫出現 “Access denied for user 'root'@'localhost' (using password: YES)”的問題

我的平臺為redhat-linux,其它版本linux類同。

請按照下列步驟依此執行,親測有效:
1.切換為root使用者,停止mysql服務,service mysqld stop
2.在當前終端中輸入mysqld_safe --user=mysql --skip-grant-tables --skip-networking
3.新開啟一個終端輸入mysql
4.進入mysql後,輸入update mysql.user set password=PASSWORD('123456') where user='root';修改密碼。
5.重新整理flush priviledges;

退出 quit;
6.重新啟動mysqld服務,service mysqld restart