Forgot your password, do not worry [MySQL database under linux forgotten password solution]


System version : CentOS Linux Release 7.7.1908 (Core)
MySQL Version : 5.6.47 MySQL Community Server (GPL)

First, the linux system MySQL forgotten password solution

1. Stop the mysql service process
service mysqld stop
Here Insert Picture Description
2. Edit the MySQL configuration file my.cnf
vim /etc/my.cnf
Here Insert Picture Description
3. Restart MySQL service
systemctl restart mysqld
4. Log database, execute the following command

mysql -u root 
use mysql;
update user set password=password("test12") where user="root";
flush privileges;
# 注意:test12 这里是我设置的密码,在这里自定义即可。

Here Insert Picture Description
5. Restart the database (to be restarted)
systemctl restart mysqld
6. Use the new password
mysql -u root -ptest12
note:-P password behind with no spaces, or in accordance with the table search, will complain
Here Insert Picture Description

Second, if you do not know your root password

Click here to see this ...... solutions have access to the device can be resolved

Published 68 original articles · won praise 394 · views 30000 +

Guess you like

Origin blog.csdn.net/weixin_42767604/article/details/105279411