Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在mysql服务器版本8.0.21 mysql社区服务器-GPL中更新mysql用户密码时出现语法错误_Mysql - Fatal编程技术网

在mysql服务器版本8.0.21 mysql社区服务器-GPL中更新mysql用户密码时出现语法错误

在mysql服务器版本8.0.21 mysql社区服务器-GPL中更新mysql用户密码时出现语法错误,mysql,Mysql,我正在尝试更新user==admin的密码,我的SQL版本是Server版本:8.0.21 MySQL社区服务器-GPL +------------------+ | user | +------------------+ | admin | | admin | | mysql.infoschema | | mysql.session | | mysql.sys | +------------------+

我正在尝试更新user==admin的密码,我的SQL版本是
Server版本:8.0.21 MySQL社区服务器-GPL

+------------------+
| user             |
+------------------+
| admin            |
| admin            |
| mysql.infoschema |
| mysql.session    |
| mysql.sys        |
+------------------+
我尝试了以上两种方法,用密码代替身份验证字符串。无论如何,它应该是身份验证字符串,因为用户表中包含的列仅包含此项。

“用户”是保留关键字。您需要在其周围加上背景标记:

UPDATE `user`
SET `authentication_string`=PASSWORD('password@1234')
WHERE `user`='admin';

这就是我更新用户名和密码的方式。感谢@ghostgambler

同样的错误,但我用这个“ALTER USER”更改了密码dbadmin@localhost由'littlehale'标识;“我认为另外,
password()
函数在最近的一个MySQL版本中被删除。但是现在实际上有多种方式来设置密码:有两个用户是admin,一个是localhost,另一个是%,我只能更改localhost的密码
ALTER user“admin”@“%”,由“password”标识。
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
UPDATE `user`
SET `authentication_string`=PASSWORD('password@1234')
WHERE `user`='admin';
use mysql;
update user set user='admin' where user='root';
flush privileges;       
ALTER USER "admin"@"%" IDENTIFIED BY 'newpassword';
ALTER USER "admin"@"localhost" IDENTIFIED BY 'newpassword';