Home > Database > Mysql Tutorial > body text

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

藏色散人
Release: 2019-02-20 14:23:20
forward
2962 people have browsed it

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;
Copy after login

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!

Related labels:
source:2cto.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template