错误1064(42000):在SQL语法中有一个错误;要将密码配置为根用户

时间:2022-03-29 14:55:07

I have just downloaded WAMP. I want to configure a password for the MySQL root user using MySQL console. No password has been set previously.

我刚刚下载了WAMP。我想使用MySQL控制台为MySQL根用户配置密码。之前没有设置密码。

The following is the input

下面是输入

    mysql-> use mysql
    Database changed
    mysql-> UPDATE user
         -> SET Password=PASSWORD<'elephant7'>
         -> 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 3

错误1064(42000):在SQL语法中有一个错误;检查与MySQL服务器版本相对应的手册,找到在第3行“WHERE user=”root”附近使用的正确语法

3 个解决方案

#1


2  

You can use:

您可以使用:

SET PASSWORD FOR 'root' = PASSWORD('elephant7');

or, in latest versions:

或者,在最新版本:

SET PASSWORD FOR root = 'elephant7' 

You can also use:

您还可以使用:

UPDATE user SET password=password('elephant7') WHERE user='root';

but in Mysql 5.7 the field password is no more there, and you have to use:

但在Mysql 5.7中,字段密码已不复存在,您必须使用:

UPDATE user SET authentication_string=password('elephant7') WHERE user='root';

Regards

问候

#2


1  

Try this:

试试这个:

UPDATE mysql.user SET password=password("elephant7") where user="root"

#3


1  

Try this one. It may be helpful:

试试这个。它可能是有用的:

mysql> UPDATE mysql.user SET Password = PASSWORD('pwd') WHERE User='root';

I hope it helps.

我希望它有帮助。

#1


2  

You can use:

您可以使用:

SET PASSWORD FOR 'root' = PASSWORD('elephant7');

or, in latest versions:

或者,在最新版本:

SET PASSWORD FOR root = 'elephant7' 

You can also use:

您还可以使用:

UPDATE user SET password=password('elephant7') WHERE user='root';

but in Mysql 5.7 the field password is no more there, and you have to use:

但在Mysql 5.7中,字段密码已不复存在,您必须使用:

UPDATE user SET authentication_string=password('elephant7') WHERE user='root';

Regards

问候

#2


1  

Try this:

试试这个:

UPDATE mysql.user SET password=password("elephant7") where user="root"

#3


1  

Try this one. It may be helpful:

试试这个。它可能是有用的:

mysql> UPDATE mysql.user SET Password = PASSWORD('pwd') WHERE User='root';

I hope it helps.

我希望它有帮助。