Reset MySQL Root Password
Reset the root password for MySQL.

MySQL Reference Manual has detail steps on how to reset password for root which are as below:


1. Stop the MySQL daemon. On windows this will usually be done via the Services panel.

2. Find the MySQL configuration file. This is called my.ini on Windows and my.cnf on Linux

3. Add the statement "skip-grant-tables". An example is shown below:

# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).



4. Start the MySQL daemon

5. Login as root to mysql
C:\mysql\bin\mysql -h localhost -u root

6. Change the root password
SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(‘MyNewPassword’);


The procedure under Windows:

1. Log on to the Windows system where MySQL is running as Administrator.

2. 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.

3. Create a text file and place the following command within it on a single line:

SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(‘MyNewPassword’);

Save the file with any name. For this example the file will be C:\mysql-init.txt.

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

Start Menu -> Run -> cmd

5. We assume MySQL is installed in C:\mysql. If MySQL is installed in another location, adjust the following commands accordingly.

If you installed MySQL using the MySQL Installation Wizard, you also may need to specify a –defaults-file option which you can lookup under the Services panel for the startup command for MySQL:

At the DOS command prompt, execute this command:

C:\> C:\mysql\bin\mysqld-nt --init-file=C:\\mysql-init.txt

Note there are TWO backslashes before mysql-init.txt. The appropriate –defaults-file setting can be found using the Services Manager:

Start Menu -> Control Panel -> Administrative Tools -> Services

The contents of the file named by the –init-file option are executed at server startup, changing the root password. After the server has started successfully, you should delete C:\mysql-init.txt.

6. Stop the MySQL server, then restart it in normal mode again. If the MySQL server is ran as a service, start it from the Windows Services window. If you start the server manually, use whatever command you normally use.

7. Connect to MySQL server by using the new password.

Media Lab Overview
LIACS Homepage
MM Conf
ACM Multimedia
Science Direct
IEEE Library
LIACS Publications
ACM Digital Library