How to Reset MySQL Root Password After Installation on Mac
When installing MySQL on Mac, it's common to encounter a situation where the root password needs to be reset. If the traditional method of updating the 'password' field with 'authentication_string' proves unsuccessful, an alternative approach may be necessary.
For those who have already set the root password once, you can utilize the following command:
mysql> UPDATE mysql.user SET Password=PASSWORD('your_new_password') WHERE User='root';
However, if you encounter an error indicating that you need to reset the password using the 'ALTER USER' statement, you may have never set a root password. To rectify this, use the following command instead:
mysql> SET PASSWORD = PASSWORD('your_new_password');
This command will set the root password for the first time.
Note: For further reference, consult the MySQL documentation: https://dev.mysql.com/doc/refman/5.6/en/alter-user.html
The above is the detailed content of How to Reset MySQL Root Password on Mac After Installation?. For more information, please follow other related articles on the PHP Chinese website!