How to modify the MySQL password in windows

Source: Internet
Author: User

I. How to change the MySQL password in windows
If you forget the MySQL password in Windows, you can do this:
1. Disable the MySQL service that is running: net stop mysql or end the mysqld.exe process in windows Task Manager or find the mysql service in the management tool and stop it;
Copy codeThe Code is as follows: C: \ Users \ Administrator> net stop mysql
The MySQL service is stopping.
The MySQL service has been stopped successfully.
2. Open the command line and go to the bin directory of mysql;
Copy codeThe Code is as follows: C :\users \ Administrator> cd C: \ Program Files \ MySQL Server 5.5 \ bin

C: \ Program Files \ MySQL Server 5.5 \ bin>
3. Input: mysqld-nt -- skip-grant-tables
Press enter. If there is no error message, you can do it;
Note: After the skip-grant-tables parameter is used, you can skip the logon verification;
Copy codeThe Code is as follows: C: \ Program Files \ 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 another command line (because the DOS window can no longer be moved) and go to the bin directory of mysql;
5. directly enter mysql and press Enter. If it succeeds, the MySQL prompt will appear>
Copy codeThe Code is as follows: C :\users \ Administrator> cd C: \ Program Files \ MySQL Server 5.5 \ bin

C: \ Program Files \ 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) 2000,201 3, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.

Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.

Mysql>
6. Switch to the mysql table
Copy codeThe Code is as follows: mysql> USE mysql;
7. You can change the password:
Copy codeThe Code is as follows: UPDATE user SET password = PASSWORD ("123456") WHERE user = "root ";
8. Refresh permissions. Do not forget:
Copy codeThe Code is as follows: mysql> flush privileges;
9. exit: (many exit methods include quit, exit, ctrl + c, \ q, etc );
10. log out or restart the computer, and then open the MySQL service. Log On with the username root and the new password.

2. Three common methods for changing the mysql password
In most cases, a user does not have the permission to change the password. Only the user who has applied for the permission or the root user can change the password;
1. Method 1: Use mysqladmin
Copy codeThe Code is as follows: mysqladmin-u root password "123456 ";
If the root user has set a password, use the following method:
Copy codeThe Code is as follows: mysqladmin-u root password-p "123456 ";
2. Method 2: run the set password command without using flush privileges;
Copy codeThe Code is as follows: mysql-u root-p
Mysql> set password for 'root' @ 'localhost' = PASSWORD ('123 ');
3. Method 3: Use UPDATE to directly edit the user table
Copy codeThe Code is as follows: mysql> USE mysql;
Mysql> UPDATE user SET Password = PASSWORD ('000000') 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.