linux mysql access denied for user ‘root’@’localhost'(using password:YES)


linux安裝完mysql后,使用程序連接報以上錯誤
解決方法,重新設置密碼,步驟如下

 

1.先停掉原來的服務

service mysqld stop

 

2.使用安全模式登陸,跳過密碼驗證

mysqld_safe --user=mysql --skip-grant-tables --skip-networking&

 

3.登陸

mysql -uroot  mysql

 

4.修改密碼

mysql  > update user set authentication_string = password('123456') 
       where user = 'root' and Host = 'localhost'

 

5.刷新權限

mysql > flush privileges;

 

6.重新使用正常模式登陸

#mysql -uroot -p
#enter password : 123456

 

可以正常登陸。

7.執行其他命令:show databases; 提示如下錯誤

You must reset your password using ALTER USER statement 
                before   executing this statement.

 

8.重新將密碼設置一遍即可

mysql > set password = password ('123456');

 

9.配置完成。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM