我使用 update user setauthentication_string=password("!QAZxsw2") where user="root";
这种语法更改我的 root 密码,但出现错误 ERROR 1064 (42000): You SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在 '("!QAZxsw2") where user="root"' at line 1
不断弹出的位置附近使用的正确语法。我不知道为什么请帮忙!
我在谷歌上搜索了这个问题,大多数文章告诉我使用 update user setauthentication_string=password("!QAZxsw2")where user ="root";
这种语法来更改我的 root密码。我找不到我哪里做错了。顺便说一句,我也尝试过这段代码set password for root@localhost = password('!QAZxsw2');
但是,仍然得到相同的结果。
mysql> update user set authentication_string=password("!QAZxsw2") 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 '("!QAZxsw2") where user="root"' at line 1
最佳答案
MySQL 5.7.5 及更早版本
mysql> 更新用户设置密码=PASSWORD("!QAZxsw2") where User='root';
MySQL 5.7.6 及更高版本
mysql> 设置 'root'@'localhost' 的密码 = PASSWORD("!QAZxsw2");
或者尝试使用以下命令,它在 mysql8 中适用于我:
mysql> 设置 'root'='!QAZxsw2' 的密码;
关于mysql - 如何修复 ERROR 1064 (42000) 语法错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57488097/