The perfect solution for Mysql to forget the root password, mysql to forget the root password
1. Change the my. cnf configuration file
1. Run the command to edit the/etc/my. cnf configuration file, that is, vim/etc/my. cnf or vi/etc/my. cnf.
2. Add skip-grant-tables under [mysqld], save and exit
3. restart mysql service: service mysqld restart
Ii. Change the root user name
1. After the restart, run the mysql command to enter the mysql command line.
2. Modify the root user password
MySQL> UPDATE mysql. user SET Password = PASSWORD ('new password') where USER = 'root'; MySQL> flush privileges; MySQL> exit
3. Comment out skip-grant-tables in/etc/my. cnf and restart mysql, that is, service mysqld restart.
Now, you can log on with the new root password!
The above section describes how to solve the problem of forgetting the root password of Mysql. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!