ERROR 1064 (42000): You have an error in your SQL syntax; Want to configure a password as root being the user

后端 未结 10 2202
再見小時候
再見小時候 2020-12-13 07:53

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.

The following is the in

相关标签:
10条回答
  • 2020-12-13 08:09

    While using mysql version 8.0 + , use the following syntax to update root password after starting mysql daemon with --skip-grant-tables option

    UPDATE user SET PASSWORD FOR 'root'@'localhost' = PASSWORD('your_new_password')
    
    0 讨论(0)
  • 2020-12-13 08:11

    From the mysql documentation version: 8.0.18:

    A superuser account 'root'@'localhost' is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command: shell> sudo grep 'temporary password' /var/log/mysqld.log Change the root password as soon as possible by logging in with the generated, temporary password and set a custom password for the superuser account:

    shell> mysql -uroot -p
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
    
    0 讨论(0)
  • 2020-12-13 08:14

    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:

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

    Regards

    0 讨论(0)
  • 2020-12-13 08:21

    I have problems with set password too. And find answer at official site

    SET PASSWORD FOR 'root'@'localhost' = 'your_password';
    
    0 讨论(0)
  • 2020-12-13 08:21

    If you have ERROR 1064 (42000) or ERROR 1046 (3D000): No database selected in Mysql 5.7, you must specify the location of the user table, the location is mysql.table_name Then the code will work.

    sudo mysql -u root -p
    
    UPDATE mysql.user SET authentication_string=password('elephant7') WHERE user='root';
    
    0 讨论(0)
  • 2020-12-13 08:27

    This is the only command that worked for me. (I got it from M 8.0 documentation)

    ALTER USER 'root'@'*' IDENTIFIED WITH mysql_native_password BY 'YOURPASSWORD';
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YOURPASSWORD';
    
    0 讨论(0)
提交回复
热议问题