Home > Database > Mysql Tutorial > body text

How to modify the MySQL database password when it is forgotten?

黄舟
Release: 2017-08-08 14:22:07
Original
2548 people have browsed it

When we forget the mysql database password, we cannot enter the database normally and cannot change the password. So how to change the password at this time? Here is a simple and commonly used way to change the password.

1. Open the folder where mysql.exe and mysqld.exe are located, copy the path address

How to modify the MySQL database password when it is forgotten?

2. Open the cmd command prompt and enter the folder where mysql.exe is located in the previous step.

How to modify the MySQL database password when it is forgotten?

3. Enter the command mysqld --skip-grant-tables and press Enter. MySQL will be skipped at this time. User Authentication. Note that the command line cannot be operated after entering this command. At this time, you can open a new command line. Note: Before entering this command, end the mysqld.exe process in the task manager to ensure that the mysql server has ended.

How to modify the MySQL database password when it is forgotten?

4. Then enter mysql directly without any login parameters and press Enter to log in to the database.

How to modify the MySQL database password when it is forgotten?

5. Enter show databases; You can see all databases indicating successful login.

How to modify the MySQL database password when it is forgotten?

6. The mysql library is where the user name is saved. Enter use mysql; to select the mysql database.

How to modify the MySQL database password when it is forgotten?

7.show tables View all tables, you will find that there is a user table, where the user name and password are stored , permissions and other account information.

How to modify the MySQL database password when it is forgotten?

8. Enter select user,host,password from user; to view account information.

How to modify the MySQL database password when it is forgotten?

##9. Change the root password and enter

update user set password=password('123456') where user='root' and host='localhost';
Copy after login

How to modify the MySQL database password when it is forgotten?

10. Check the account information again, select user,host,password from user; You can see that the password has been modified.

How to modify the MySQL database password when it is forgotten?

11. Exit the command line, restart the mysql database, and try to log in with a new password.

1How to modify the MySQL database password when it is forgotten?

12. Tested to log in to mysql without a password and found that I could still log in, but when displaying the database, I could only see two databases. Explain. Skipping password verification after reboot has been eliminated.

1How to modify the MySQL database password when it is forgotten?

13. The reason why I can still log in without a password after restarting the database is because there is an account in my database that does not require a password. .

1How to modify the MySQL database password when it is forgotten?

Note

Pay attention to several places where you need to restart the database

The above is the detailed content of How to modify the MySQL database password when it is forgotten?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!