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

后端 未结 10 2203
再見小時候
再見小時候 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:30

    On MySQL 8.0.15 (maybe earlier than this too): the PASSWORD() function does not work anymore, so you have to do:

    Make sure you have stopped MySQL first (Go to: 'System Preferences' >> 'MySQL' and stop MySQL).

    Run the server in safe mode with privilege bypass:

    sudo mysqld_safe --skip-grant-tables
    mysql -u root
    UPDATE mysql.user SET authentication_string=null WHERE User='root';
    FLUSH PRIVILEGES;
    exit;
    

    Then

    mysql -u root
    ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
    

    Finally, start your MySQL again.

    Enlighten by @OlatunjiYso in this GitHub issue.

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

    Try this one. It may be helpful:

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

    I hope it helps.

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

    I was using MySQL 8 and non of the above worked for me.

    This is what I had to do:

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
    
    0 讨论(0)
  • 2020-12-13 08:36

    Try this:

    UPDATE mysql.user SET password=password("elephant7") where user="root"
    
    0 讨论(0)
提交回复
热议问题