Resetting MySQL 8 root Password After Install using ALTER USER Statement
You have encountered an issue where resetting the MySQL root password using the traditional method fails. This is because the password needs to be set using the ALTER USER statement instead.
First-Time Password Setup:
If this is your first time setting the root password, execute the following command:
mysql> SET PASSWORD = PASSWORD('your_new_password'); Query OK, 0 rows affected, 1 warning (0.01 sec)
Existing Password Reset:
If you need to reset the password for a non-first-time setup, follow these steps:
mysql> UPDATE mysql.user SET Password=PASSWORD('your_new_password') WHERE User='root';
Additional Notes:
Reference:
[ALTER USER Syntax](https://dev.mysql.com/doc/refman/5.6/en/alter-user.html)
The above is the detailed content of How to Reset MySQL 8 Root Password After Install using ALTER USER?. For more information, please follow other related articles on the PHP Chinese website!