How to troubleshoot MySQL forgot password under windows

Source: Internet
Author: User

mysql5.0

Http://www.jb51.net/article/21984.htm
Method One:

1. Enter in the DOS window

Or

2, open a DOS window, this need to switch to the MySQL bin directory.
In the bin directory, typically create a batch 1.bat, the content is Cmd.exe run a moment to switch to the current directory, and then enter

3. Open a DOS window again

4. Enter:

5, use the Task Manager, find the MYSQLD-NT process, end the process
or the following steps
1. Stop MySQL service, CMD Open DOS window, enter net stop MySQL
2, in the CMD Command Line window, go to MySQL installation directory such as E:\Program files\mysql\mysql Server 5.0\bin
Demonstration command:
Enter e: Carriage return,
Enter CD "E:\Program files\mysql\mysql Server 5.0\bin"
Note that double quotation marks are also entered so that you can enter the MySQL installation directory.
3, enter the MySQL security mode, that is, when MySQL up, you can enter the database without entering a password.
The command is:

4. Reopen a CMD command-line window and enter

Mysql-uroot-p, log in to MySQL using a blank password (without entering the password, press ENTER directly)

5, enter the following command to start modifying the root user's password (note: there is a "dot" in the middle of the Mysql.user command)

Mysql.user: Database name. Table Name
mysql> Update Mysql.user Set Password=password (' New password ') where user= ' root ';
6, Refresh the permissions table
mysql> flush Privileges;
7, exit
Mysql> quit


So the MySQL Super Admin account Root has been reset, and then in the Task Manager to end the Mysql-nt.exe this process, restart MySQL!

(You can also restart the server directly)
After MySQL restarts, you can log in to MySQL with the new root password!

Method Two:

First create a new pwdhf.txt in the MySQL installation directory and enter the text:

The red part is the new password that needs to be set
Stop the MySQL service with the Windows Service Administration tool or Task Manager (Task Manager K-Drop MYSQLD-NT process)
DOS command prompt to the bin directory under the MySQL installation directory as mine is

D:\Program Files\mysql\mysql Server 5.1\bin
Then run:

After execution, stop the MySQL database service (Task Manager k off Mysqld-nt process), and then restart MySQL in normal mode

mysql5.1 or above

1, first check whether the MySQL service is started, if it has been started to stop the service, can be run in the Start menu, using the command:

2. Open the first CMD window, switch to the MySQL bin directory and run the command:

Mysqld--defaults-file= "C:\Program files\mysql\mysql Server 5.1\my.ini"--console--skip-grant-tables

Comments:

This command starts the MySQL service by skipping permission security checks, so that when you connect to MySQL, you do not have to enter a user password.

3. Open a second CMD window and connect to MySQL:

Enter the command:

Mysql-uroot-p

Appear:

Enter Password:

Enter the carriage directly here without entering the password.

Then there will be a login success message,

4. Use the command:

show databases;

5. Switch to MySQL database using the command:

Use MySQL;

6. Use the command to change the root password to 123456:

UPDATE user SET Password=password (' 123456 ') where user= ' root ';

7. Refresh Permissions:

FLUSH privileges;

8. Then exit and re-login:

Quit

Re-login:

Mysql-uroot-p

9, enter the password prompt, enter a new password to log in:

Enter Password: ***********

Display login Information: Success is all OK.

10. Restart MySQL Service

net start MySQL

How to troubleshoot MySQL forgot password under windows

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.