Windows forgot the Mysql password modification method _mysql

Source: Internet
Author: User
Tags flush

One, Windows to modify the MySQL password method
If you forget your MySQL password under Windows, you can do this:
1. Close the running MySQL service: net stop MySQL or end the Mysqld.exe process in Windows Task Manager or find the MySQL service in the service of the admin tool, stop it;

Copy Code code as follows:
C:\users\administrator>net stop MySQL
The MySQL service is stopping.
The MySQL service has stopped successfully.

2. Open the command line and go to the MySQL bin directory;
Copy Code code as follows:
C:\USERS\ADMINISTRATOR>CD C:\Program files\mysql\mysql Server 5.5\bin

C:\Program Files\mysql\mysql Server 5.5\bin>


3. Input: Mysqld-nt--skip-grant-tables
Then enter, if there is no error message, on the line;
Note: After the skip-grant-tables parameter is used, you can skip the login checksum;
Copy Code code as follows:
C:\Program files\mysql\mysql Server 5.5\bin>mysqld-nt--skip-grant-tables
140317 13:23:11 [Warning] option ' new ': Boolean value ' t ' wasn ' t recognized. Set
to OFF.

4. Open a command line again (because that DOS window is already unable to move), also go to the MySQL bin directory;
5. Directly enter MySQL and return, if successful, will appear MySQL prompt >
Copy Code code as follows:
C:\USERS\ADMINISTRATOR>CD C:\Program files\mysql\mysql Server 5.5\bin

C:\Program Files\mysql\mysql Server 5.5\bin>mysql
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server version:5.5.35 MySQL Community Server (GPL)

Copyright (c), 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark the Oracle Corporation and/or its
Affiliates. Names may trademarks of their respective
Owners.

Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>


6. Switch to MySQL table
Copy Code code as follows:
Mysql>use MySQL;

7. You can modify the password:
Copy Code code as follows:
UPDATE user SET Password=password ("123456") WHERE user= "root";

8. Refresh the permissions, do not forget:
Copy Code code as follows:
Mysql>flush privileges;

9. Exit: (Exit method Many have quit, exit, CTRL + C, \q, etc.);
10. Log off or restart the computer, and then open the MySQL service, using the username root and the settings of the new password can be logged in.

Two, change the MySQL password commonly used three kinds of methods
In most cases, the average user does not have permission to change the password, only if the permission is applied or the root user can change the password;
1. Method 1: Using Mysqladmin

Copy Code code as follows:
mysqladmin-u root password "123456";

If Root has already set the password, use the following method
Copy Code code as follows:
Mysqladmin-u root password-p "123456";

2. Method 2: Use Set password command, do not need to use flush privileges;
Copy Code code as follows:
Mysql-u root-p
mysql> SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' 123456 ');

3. Method 3: Edit the user table directly with update
Copy Code code as follows:
mysql> use MySQL;
mysql> UPDATE user SET Password = Password (' 123456 ') WHERE user= ' root ';

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.