Home  >  Article  >  Database  >  How to solve the problem of forgetting the password of mysql5.7 database

How to solve the problem of forgetting the password of mysql5.7 database

藏色散人
藏色散人forward
2019-02-20 14:23:202924browse

How to solve the problem of forgetting the password of mysql5.7 database

1. First stop the mysql service

2. Edit the configuration file my.cnf

Add skip-grant-tables in [mysqld] Configuration item, the function of this configuration is to "adjust the restrictions of the permission table, log in data directly without password verification", but do not forget to delete this item in the production environment.

3. Start msyql service

Log in to the database, you don’t need a password, you can enter the database directly.

4. Change the password

Directly execute:

update mysql.user set authentication_string=password('123456') where user='root' and host='localhost';
flush privileges;

5. Delete the skip-grant-tables configuration item in my.cnf and restart the mysql service

6. You can use the new password to log in to the database.

Recommended tutorial: "mysql tutorial"http://www.php.cn/course/list/51.html

The above is the detailed content of How to solve the problem of forgetting the password of mysql5.7 database. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:2cto.com. If there is any infringement, please contact admin@php.cn delete