How can I forget the root password for MySQL5.7 on Mac? mysql5.7root
Follow these steps to forget the root password of mysql5.7:
1. Stop the MySQL service in the system preference settings.
2. Run the following command to start MySQL in safe mode:
Cd/usr/local/mysql/bin
Sudo./mysqld_safe -- skip-grant-tables
3. Open a new command line window and execute
Update mysql. user set authentication_string = PASSWORD ('your password') where User = 'root ';
Flush privileges;
Note: On the internet, update mysql. user set password = PASSWORD ('000000') where User = 'root' is generally executed. However, the execution fails, prompting that no password field exists.
4. Close the MySQL database. I will directly kill the process because I cannot close MySQL in the window started in step 1.
5. Start the MySQL service in the system preference settings.
6. Run mysql-u root-p and enter the password to log on to MySQL.
7. After the First Login is installed, the system will prompt that the PASSWORD has expired. You can run the set password for root @ 'localhost' = PASSWORD ('new password') command to change the PASSWORD.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.