解決ubuntu下mysql的'Access denied for user 'root'@'localhost' (using password: YES)'


一般出現這種情況,只要重新修改下root密碼

解決方法:
1.打開/etc/mysql/debian.cnf文件,里面存儲了系統管理員的密碼

2. 輸入命令:

mysql -udebian-sys-maint -p

再輸入對應debian.cnf里對應的密碼,以管理員身份進去

3.進入控制台后.按以下步驟進行:

 

 

update user set password=PASSWORD('新密碼') where user='root';FLUSH PRIVILEGES;

 

如果你的mysql是5.7版本后的  

  1.  
    password字段已經改成authentication_string這個字段了,那就輸入
  2.  
    update user set 
    authentication_string=PASSWORD('新密碼') where user='root';

     

此時可以輸入quit;退出
sudo /etc/init.d/mysql restart
重啟MySQL
用root帳號登錄


免責聲明!

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



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