How to retrieve the root password of mysql database in linux system
Mysql forgets root password under linux
1. Shut down mysql service
Service mysqld stop
Second, modify the mysql configuration file
Modify / etc/my.cnf and add it under the [mysqld] module
Skip-grant-tables # # ignore the mysql permission problem and log in directly
After modification
Start the mysql service and log in to the mysql database directly
You don't need a password to log in to the mysql database at this time. You can log in directly.
Service mysqld start;mysql-u root-p
Change the root password
Mysql > update mysql.user set password=PASSWORD ('new_password') where User='root'; mysql > flush privileges; mysql > quit
Change my.cnf back, and then restart the mysql service
Service mysqld restart
VI. Completion
Just log in with the new password.
What if I forget the root password of the mysql database under linux? For more details, please pay attention to other related articles!