h1

Reset MySQL Root Password (for Windows)

August 8, 2009

If you happen to lose your root password to a MySQL Server for Windows. Here are the step you’ll need to reset it.

Step 1: Stop MySQL Service

Stop the MySQL Service from Control Panel -> Administrative Tools -> Services or simply just run services.msc from the run command dialog (I personally prefer the later as it’s faster to get there.)

Step 2: Run mysqld without checking for priveleges

Note: You might want to block the mysql port for this step as it leaves your db server vulnerable for the duration of the procedure. SHEILDS UP, SCOTTY!!!


Open a Command Prompt (shortcut is to run cmd from the run command dialog).

Note: if you have the MySQL bin directory on your PATH you can just execute the following commands immediately else you’ll need to cd to the bin directory before doing so. (or add it to your PATH, your choice)


Run this command:

mysqld-nt --skip-grant-tables

Note: You’ll not be able to use this command prompt after running the command above until the MySQL server is stopped again.


Step 3: Reseting your password

Open a new Command Prompt (shortcut is to run cmd from the run command dialog).

Note: if you have the MySQL bin directory on your PATH you can just execute the following commands immediately else you’ll need to cd to the bin directory before doing so. (or add it to your PATH, your choice)


Run this command:

mysql –u root mysql

You’ll now be in the mysqld command prompt execute the following to reset the password:

UPDATE USER SET PASSWORD=PASSWORD('newpassword') WHERE USER='root';
FLUSH PRIVILEGES;
quit;

Step 4: Stop MySQL from Step 2 and Start the MySQL Service again.

Now that you are back at the prompt again from the last step of Step 3, run this command:

mysqladmin shutdown

Note: The command prompt window from Step 2 will be back to the prompt.


Start the MySQL Service from Control Panel -> Administrative Tools -> Services or simply just run services.msc from the run command dialog (I personally prefer the later as it’s faster to get there.)

TA DA!!!!…


Note: This article was written based on information from http://www.mydigitallife.info/2006/06/06/change-and-reset-mysql-root-password/ to illustrate changing the mysql password on windows.


Leave a Comment