Reset MySQL root password using ALTER USER statement after install on Mac

后端 未结 19 2271
慢半拍i
慢半拍i 2020-11-29 14:21

I\'m new to the whole Mac experience. I recently installed MySQL and it seems I have to reset the password after install. It won\'t let me do anything else.

Now I al

19条回答
  •  旧时难觅i
    2020-11-29 14:59

    If this is NOT your first time setting up the password, try this method:

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

    And if you get the following error, there is a high chance that you have never set your password before:

    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. 
    

    To set up your password for the first time:

    mysql> SET PASSWORD = PASSWORD('your_new_password');
    Query OK, 0 rows affected, 1 warning (0.01 sec)
    

    Reference: https://dev.mysql.com/doc/refman/5.6/en/alter-user.html

提交回复
热议问题