MySQL Index

***DISCLAIMER***
The author of this site makes no warranties, express or implied, and assumes no responsibility for the use of the materials presented here. Any use of these materials is strictly at the risk of the user.

Change forgotten MySQL Root Password

(Article ID: 000922)

To change a forgotten MySQL root password on a Windows MySQL installation do the following:

  1. Start the Services Administrative Tool (Start>Run>services.msc).
  2. Scroll down to the MySQL service in question (default: MySQL).
  3. Double-click on the service in question to open its properties page.
  4. Highlight the contents of the Path to executable: field and press CTRL+C (to copy).
  5. Click Stop to stop the service.
  6. Start a DOS session (Start>Run>cmd).
  7. Right-click in the DOS window to paste the command to start the service.
    NOTE: In case Quick Edit mode is not enabled, select Paste from the popup menu.
  8. Erase the instance name from the command line (the last argument, i.e. MySQL).
  9. Add the following commands to the command line:
    --safe-mode --skip-grant-tables
  10. Press ENTER.
    NOTE: The command prompt will not return until this process has been terminated later.
  11. Start a second DOS session (Start>Run>cmd).
  12. Enter the following command and press ENTER:
    mysql -u root mysql -e "UPDATE user SET Password=PASSWORD('NewPassword') WHERE user='root'; FLUSH PRIVILEGES;".
    NOTE: The NewPassword is where the desired new password should be entered.
  13. Type the following command to shutdown the MySQL Server service and press ENTER:
    mysqladmin -u root -p shutdown.
  14. Type in the password that was just set for the root account at the prompt and press ENTER.
  15. Restart the MySQL Server service normally from the Services Administrative Tool (or restart the server).

The password may either be reset to a permanent password during the command line session (NOT RECOMMENDED) or through the MySQL Query Browser (or equivalent program).

To change the password during the command line session enter the password in place of NewPassword. Be sure to leave the single quotes in place.

To change the password using a query analyzer do the following:

  1. Launch the query analyzer of your choice.
  2. Log on using the root account and the account's current password.
  3. Run the following query:
    SET PASSWORD = PASSWORD('NewPassword').

Make sure that the password you want to use takes the place of NewPassword.
If you want to change the password for a different account do the following:
SET PASSWORD FOR 'username' = PASSWORD('NewPassword').

***DISCLAIMER***
The author of this site makes no warranties, express or implied, and assumes no responsibility for the use of the materials presented here. Any use of these materials is strictly at the risk of the user.
***DISCLAIMER***
The author of this site makes no warranties, express or implied, and assumes no responsibility for the use of the materials presented here. Any use of these materials is strictly at the risk of the user.