无法使用更新语句更改 mysql 用户密码

Unable to change mysql user password using update statement

我可以使用设置密码方法和更改用户语句来更改 mysql 用户密码。但是,更新用户命令失败。

mysql> UPDATE USER SET PASSWORD=PASSWORD('George7') where USER = 'george' and host='localhost'; 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 '('George7') where USER = 'george' and host='localhost'' at line 1

我下面的语句有什么错误:

UPDATE USER SET PASSWORD=PASSWORD('George7') where USER = 'george' and host='localhost';

我猜您使用的是 MySQL 8.0。您必须在 MySQL 8.0.

中使用 SET PASSWORD

https://dev.mysql.com/doc/refman/8.0/en/encryption-functions.html#function_password 说:

  • PASSWORD(str)

    This function was removed in MySQL 8.0.11.