mysql 修改密碼時遭遇 update 命令報錯?
問題描述:
嘗試使用 update 命令修改 mysql 用戶密碼時,出現以下錯誤:
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 '('wang') where user='alex'' at line 1
答案:
錯誤提示表明在 sql 語句中存在語法錯誤。在新版本的 mysql(5.7 及更高版本)中,不再支持使用 update 命令來修改密碼。需要使用以下語句:
兼容低版本密碼套件
alter user 'wang'@'localhost' identified with mysql_native_password by '新密碼';
或
使用較新密碼套件
ALTER USER 'wang'@'localhost' IDENTIFIED BY '新密碼';
其中,wang 代表要修改密碼的用戶名,localhost 代表受限的主機,如果需要任意主機,可以使用通配符 %。
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END