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再次登陸即需要輸入剛剛設置的密碼。
具體請參考文章:
