Home > Database > Mysql Tutorial > What should I do if I forget my login password for mysql database? How to modify?

What should I do if I forget my login password for mysql database? How to modify?

php是最好的语言
Release: 2018-08-02 17:42:27
Original
58344 people have browsed it

Nowadays, there are many places where we need to set passwords. There will always be times when we get confused or forget them. I won’t go into details about the others. Let’s talk about the focus of this article. What should we do if we forget the mysql root password? How to retrieve it, or how to change mysql database login password? apache php mysql Here I will share with you a simple and commonly used method to change passwords:

1. First find and open the folder where mysql.exe and mysqld.exe are located (in the bin file of the Mysql you installed folder), copy the path address. As shown in the figure below

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

#(I have to run it as an administrator here) It’s useless to open CMD directly)

3. Enter the command mysqld --skip-grant-tables and press Enter. At this time, the user verification of mysql is skipped. Note that the command line cannot be operated after entering this command. At this time, you can open a new command line. Please note: Before entering this command, first end the mysqld.exe process in the task manager, and ensure that the mysql server has ended before performing this operation.

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

5. Enter show databases; You can see all database instructions for successful login.

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

#7.show tables View all tables, you will find that there is a user table, which stores account information such as user names, passwords, permissions, etc.

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

9. To change the root password, enter update user set password=password('root') where user='root' and host='localhost'; change the password here Change to root.

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

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

This concludes the introduction to changing the mysql database login password. Do you know how to do it now? With this method, you don’t have to worry about forgetting your password. Of course, it’s best to set one you often use. After all, changing it every day is quite troublesome and a waste of time. If you have any questions, please feel free to ask and communicate. I wish everyone a happy study.

Related articles:

How to solve the problem if the mysql database administrator forgets the password

How to change the password when the MySQL database forgets it?

Related videos:

Database mysql video tutorial

###

The above is the detailed content of What should I do if I forget my login password for mysql database? How to modify?. 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