mysql - 在 mysql 服务器版本中更新 mysql 用户密码的语法错误:8.0.21 MySQL Community Server - GPL
问题描述
我正在尝试更新用户 == admin 的密码,我的 SQL 版本是Server version: 8.0.21 MySQL Community Server - GPL
+------------------+
| user |
+------------------+
| admin |
| admin |
| mysql.infoschema |
| mysql.session |
| mysql.sys |
+------------------+
update user set authentication_string=PASSWORD('password@1234') where user='admin';
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 '('password@1234') where user='admin'' at line 1
mysql> UPDATE user
-> SET authentication_string = PASSWORD('password@1234')
-> WHERE user = 'admin' 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 '('password@1234')
WHERE user = 'admin' AND
host = 'localhost'' at line 2
我已经尝试了上述两种方法,并用密码代替了 authentication_string。无论如何它应该是 authentication_string 因为用户表只包含这个列
解决方案
“用户”是保留关键字。你需要用反引号括起来:
UPDATE `user`
SET `authentication_string`=PASSWORD('password@1234')
WHERE `user`='admin';
推荐阅读
- recaptcha - 站点所有者的错误:波斯名称和域网站的站点密钥的域无效
- javascript - 登录成功后在页面加载时显示模式
- python - 防止 pip 安装某些依赖项
- sql - Oracle 中 DISTINCT 的用法
- php - 将实例化对象转移到类中
- java - 从另一个类检索的最终静态 LocalDateTime 正在抛出 java.lang.ExceptionInInitializerError
- system-design - 系统设计中多级缓存的缺点
- java - Java - 如何从属性文件中读取冒号而不转义文件内?
- python - 为什么我的随机数游戏无法正常运行?
- python - 如何在熊猫数据框中获得所需的行和列名?