Home >Database >Mysql Tutorial >What should I do if I forget the root password of mysql database under Linux?
mysql forget root password under linux
1. Close the mysql service
service mysqld stop
2. Modify the mysql configuration File
Modify /etc/my.cnf and add
skip-grant-tables ##忽略mysql权限问题,直接登录
after modification
# under the [mysqld] module ## 3. Start the mysql service and log in to the mysql database directly At this time, you do not need a password to log in to the mysql database, you can log in directlyservice mysqld start; mysql -u root -p4. Change the root password
mysql> update mysql.user set password=PASSWORD('new_password') where User='root'; mysql> flush privileges; mysql> quit;5 , change my.cnf back, and then restart the mysql service
service mysqld restart;6. CompleteJust log in with the new passwordRecommended tutorial: "
mysql tutorial 》
The above is the detailed content of What should I do if I forget the root password of mysql database under Linux?. For more information, please follow other related articles on the PHP Chinese website!