A workaround for MySQL forgot root password under windows

Source: Internet
Author: User
Tags mysql in mysql update

Method One:

1. Enter or in the DOS window net stop mysql5 net stop mysql
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 entermysqld-nt --skip-grant-tables;

Or

mysqld --skip-grant-tables;

Do not close the window

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 steps1, stop MySQL service, CMD Open DOS window, enter net stop MySQL 2, in cmd command Line window, go to MySQL installation directory such as E:\Program files\mysql\mysql Server 5.0\bin Demonstration command: Input E : Enter the CD "E:\Program files\mysql\mysql Server 5.0\bin" Note that double quotes 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. Command: Mysqld-nt--skip-grant-tables 4, reopen 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, quit mysql> quit so the MySQL Super Admin account Root has been reset, the next 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 (' * * * * * * ');
Red part for new password to be set with Windows Service Management tool or task Manager to stop the MySQL service (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 runs: 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

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.