Home  >  Article  >  Database  >  How to reset password in mysql

How to reset password in mysql

little bottle
little bottleOriginal
2019-05-29 15:52:4315369browse

How to reset password in mysql

1. Remember the password and prepare to change the new password

Connect to the mysql database and enter the command in cmd:

mysql -uroot -p

Then press Enter to enter the password

2. Switch database:

use mysql;

*mysql is the default database of the system. It has a user table that stores the user name and password of the current database user. *

3. Modify the user table password in the mysql database

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

*password('root') is a function, and root is the modified new password, which is passed to the password() function as a parameter *

4. Restart the mysql service.

2. Forgot password and prepare to reset password

Stop the mysql service and execute the command in the cmd window:

compmgmt.msc

Open Computing Management——>Services and Applications --->Service—>mysql, stop the service.

2. Open the cmd window and execute the command in the window:

mysqld --skip-grant-tables  //(后面不要加分号)

This command is to skip the security check

After executing this command, we will see the cursor flashing , indicating that a service has been opened, which is somewhat similar to the tomcat server.

3. Keep the current cmd window open, open another cmd window, connect to the mysql database mysql -u root, switch the database use mysql; modify the user table password in the mysql database; for details, refer to the above "Remember the password" Prepare to change the new password" operation.

4. Close the two cmd windows, Ctrl Shift Esc to open the task manager, find the mysqld process, and kill it.

5. Start the mysql service:

Open Computing Management——>Services and Applications——>Services——>mysql, start the service.

The above is the detailed content of How to reset password in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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