9/19/2007

mysql server password reset in windows

Thanks to codewizard from p2p community forum, reseting password of your mysql server is a breeze. Saved my server once already. =)

The source can be found here.

The procedure under Windows:
Log on to your system as Administrator.
Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager:

Start Menu -> Control Panel -> Administrative Tools -> Services
Then find the MySQL service in the list, and stop it. If your server is not running as a service, you may need to use the Task Manager to force it to stop.

Open a console window to get to the DOS command prompt:

Start Menu -> Run -> cmd

We are assuming that you installed MySQL to `C:\mysql'. If you installed MySQL to another location, adjust the following commands accordingly. At the DOS command prompt, execute this command:

C:\> C:\mysql\bin\mysqld-nt --skip-grant-tables

This starts the server in a special mode that does not check the grant tables to control access.

Keeping the first console window open, open a second console window and execute the following commands (type each on a single line):

C:\> C:\mysql\bin\mysqladmin -u root flush-privileges password "newpwd"

C:\> C:\mysql\bin\mysqladmin -u root -p shutdown

Replace ``newpwd'' with the actual root password that you want to use.

The second command will prompt you to enter the new password for access. Enter the password that you assigned in the first command.
Stop the MySQL server, then restart it in normal mode again. If you run the server as a service, start it from the Windows Services window. If you start the server manually, use whatever command you normally use.

You should now be able to connect using the new password.

No comments: