mysql8安裝后如何修改root密碼


mysql5.7.9之后,就沒有了password函數,所以,使用傳統的password()函數修改root密碼的話,就會提示sql錯誤

 

 UPDATE user SET authentication_string = password('123456') WHERE User='root';

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('123456') WHERE User='root'' at line 1

 

 

正確設置密碼的方法是:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

此時提示修改成功,退出mysql再次登陸即需要輸入剛剛設置的密碼。

 

具體請參考文章:

https://newsn.net/say/mysql8-password.html


免責聲明!

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



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