Home  >  Article  >  Database  >  ECS Windows server MySQL reset root password

ECS Windows server MySQL reset root password

藏色散人
藏色散人forward
2019-02-15 11:47:032262browse

ECS Windows server MySQL can refer to the following method to reset the root password. Please refer to the actual situation. Please make a backup before operation.

1. Stop the MySQL service:

First check whether the MySQL service is started. If it is started, stop the MySQL service first. There are two ways to stop it:

1) Explanation [Start] Menu--[Run]--Execute the "cmd" command to open the command prompt window and execute

net stop MySQL5.1

ECS Windows server MySQL reset root password

Note: "MySQL5.1" here refers to The full name of the MySQL service must be subject to the actual situation. The query command is as follows:

sc query  state=all | findstr  /i  mysql

After the command is executed, the full name of the MySQL service will be displayed.

ECS Windows server MySQL reset root password

You can also view the full name of the MySQL service in [Management Tools]--[Services].

ECS Windows server MySQL reset root password

2) In [Management Tools]-[Services], find the MySQL service, double-click the MySQL service name, and click [Stop].

ECS Windows server MySQL reset root password

2. Skip permission security check:

Execute command:

C:\websoft\mysql\bin\mysqld --defaults-file="C:\websoft\mysql\my.ini" --console --skip-grant-tables

After this command is executed, the MySQL service will run. When you connect to MySQL later, you don't need to enter the password temporarily.

ECS Windows server MySQL reset root password

Note: C:\websoft\mysql\bin\mysqld --is the directory path of the MySQL service process

--defaults-file="C :\websoft\mysql\my.ini" -- is the directory path of the MySQL configuration file. Please refer to the on-site environment.

3. Log in to MySQL:

Open a new command prompt window and log in to MySQL. The command is as follows:

C:\websoft\mysql\bin\mysql -uroot -p

In the Enter password: interface, press Enter directly (no need password), a successful login message appears.

ECS Windows server MySQL reset root password

4. Reset password:

Execute the following commands in sequence:

use mysql;
UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
FLUSH PRIVILEGES;
quit

Note: "newpassword" is the new one Password, please define your own password.

5. Verify password:

The MySQL password has been reset through the above steps. You can log in again for verification. The command is as follows:

C:\websoft\mysql\bin\mysql -uroot -p
Enter password: *********** 在此界面输入新的密码即可登录。

Note: After the password change is completed, if The user's website program uses the above modified account to connect to the database. Please promptly adjust the password used to connect to the database in the program to prevent the user's program business from being unable to connect to the database.

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

The above is the detailed content of ECS Windows server MySQL reset root password. For more information, please follow other related articles on the PHP Chinese website!

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