Mysql forgot password, reset process

After mysql forgets the root password, you can modify the mysql configuration file and add skip-grant-tables to skip password verification

Specific steps are as follows:

1. Modify the mysql configuration file

Add the following configuration

skip-grant-tables

vim /etc/my.conf

2. Restart the mysql service

systemctl restart mysql

3. Enter the database

 4. Enter the mysql library

use mysql

View user table user information

select * from user \G;

6. Modify the password. Note: the password must contain uppercase and lowercase letters + special characters + numbers

update user set authentication_string=password('123456')where user='root';

7. Exit the database and delete the configuration added by the configuration file

 

8. Restart the database

systemctl restart mysqld

 9. Login to the database

10. Execute the sql command prompt to use alter user to reset the password

 11. Use alter user to reset password

alter user root@'localhost' identified by '123456';

12. The input mysql statement is normal, and the password modification is completed

At this point, the password change is complete!

Guess you like

Origin blog.csdn.net/m0_65307735/article/details/129183078