Windows Mysql Forget root password solution _mysql

Source: Internet
Author: User
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.
Generally in the bin directory to create a batch of 1.bat, the content is cmd.exe run it can switch to the current directory, and then enter
Mysqld-nt--skip-grant-tables;

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

4, Input:
Copy Code code as follows:

Use MySQL
Update user set Password=password ("New_pass") where user= "root";
Flush privileges;
Exit

5, use Task Manager, find mysqld-nt process, end process
or the following steps
1, stop the MySQL service, CMD Open the DOS window, input net stop MySQL
2, in the CMD Command Line window, enter the MySQL installation directory such as E:\Program files\mysql\mysql Server 5.0\bin
Model command:
Enter e: Carriage return,
Enter CD "E:\Program files\mysql\mysql Server 5.0\bin"
Note that double quotes also need to be entered so that you can enter the MySQL installation directory.
3, enter the MySQL security mode, that is, when MySQL up, do not enter the password can enter the database.
Command is: Mysqld-nt--skip-grant-tables
4, reopen a CMD command line window, enter mysql-uroot-p, use the way of NULL password login mysql (do not enter the password, directly press ENTER)
5, enter the following command to begin modifying the root user's password (note: there is a "dot" in the Mysql.user in the command)
mysql> Update Mysql.user Set Password=password (' New password ') where user= ' root ';
6, Refresh the permission table
mysql> flush Privileges;
7, exit
Mysql> quit
This MySQL Super Administrator account root has been reset, then in the Task Manager to end the process of Mysql-nt.exe, restart MySQL! (You can also restart the server directly)
After MySQL reboot, you can use the new set of root password login MySQL!
Method Two:

First in the MySQL installation directory to create a new pwdhf.txt, input text: SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' * * *);

Red part for new password to be set
Stop the MySQL service with the Windows Service Management tool or Task Manager (Task Manager k off the MYSQLD-NT process)
DOS command prompt to the bin directory under the MySQL installation directory like mine is D:\Program files\mysql\mysql Server 5.1\bin
Then run: Mysqld-nt--init-file=. /pwdhf.txt
Complete stop MySQL database service (Task Manager k off Mysqld-nt process), and then restart in normal mode MySQL can be

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.