首页 > 解决方案 > 更新或更改表根用户的 SQL 语法错误

问题描述

新安装后ubuntu 20.04我得到错误与root用户连接到mysql。使用后的以下命令

sudo mysqld_safe --skip-grant-tables --skip-networking
mysql -u root

我收到语法错误,无法更新 root 密码:

mysql版本:

mysql  Ver 8.0.22-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))

命令:

update `user` set `authentication_string`=PASSWORD("") 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 '("") where `User`='root'' at line 1

当我尝试使用Alter命令时,我收到此消息:

ALTER USER 'root'@'localhost' IDENTIFIED BY '';
    >ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

标签: mysqlubuntuunix

解决方案



尝试使用单引号,而不是双引号或设置密码不要使用空字符串
update user set `authentication_string`=PASSWORD('') where user='root';

或者

update user set `authentication_string`=PASSWORD('yourpassword') where user='root';

然后冲洗!

flush privileges;

推荐阅读