A workaround for MySQL forgot root password under windows

Source: Internet
Author: User
Tags mysql in

Under Windows MySQL forgot root password solution, encounter this problem of friends can refer to. Method One:

1. Enter net stop MYSQL5 or net stop MySQL under DOS window

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
Mysqld-nt--skip-grant-tables;

3. Open a DOS window again, mysql-u root

4. Enter:
Copy CodeThe code is as follows:
Use MySQL
Update user set Password=password ("New_pass") where user= "root";
Flush privileges;
Exit
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: Mysqld-nt--skip-grant-tables
4, re-open a CMD command line window, enter mysql-uroot-p, use a blank password to log in to MySQL (Do not enter the password, directly press ENTER)
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> 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, enter the text: SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' * * * * * * ');

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: Mysqld-nt--init-file=. /pwdhf.txt
After execution stop MySQL database service (Task Manager k off Mysqld-nt process), and then restart MySQL in normal mode Articles you may be interested in:
    • How to modify MySQL password under Windows
    • How to change the root password without restarting MySQL
    • mysql--4 ways to change the root password (take windows as an example)
    • MySQL root password forgot, view or modify the workaround (graphic introduction)
    • MYSQL Change root Password command summary
    • MySQL add user, Authorization, change password and other statements
    • How to implement MySQL forgot password recovery password
    • The best way to test MySQL password forgotten solution
    • A summary of solutions to the forgotten MySQL password

A workaround for MySQL forgot root 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.