Resetting MySQL Password on Windows Server

A practical guide to changing MySQL passwords easily or manually when needed

Posted by Hüseyin Sekmenoğlu on July 21, 2013 Backend Development

πŸ› οΈ Changing the MySQL Password on Windows Server

Sometimes you need to reset your MySQL password on a Windows server either because you forgot it or you simply want to update it. Here are two main approaches: the easy way and the traditional method.


πŸš€ Easy Method Using MySQL Workbench

If you installed MySQL via Microsoft Web Platform Installer, the root password is likely the same as your Windows Administrator password. This makes resetting it straightforward.

Steps:

  1. Install MySQL Workbench
    If not already installed, download and install MySQL Workbench.

  2. Access the Server
    Launch MySQL Workbench. On the right side, locate the Server Administration section. Double-click the entry labeled Local MySQL.

  3. Enter Your Current Password
    Provide your current root password. If this is your first login, try using your Windows Administrator password.

  4. Change the Password
    On the left panel, click Users and Privileges.
    Select the user you want to update, enter the new password and click Apply to save your changes.

This method works great if you still have access to the root account.


πŸ”„ Alternative Method Using CMD and Script File

If you have forgotten the password or the Workbench method does not work, here’s a more manual method.

Step-by-Step Instructions:

  1. Create a Script File
    Open Notepad and paste the following lines:

    Save this file as D:\reset.txt or any preferred path.

UPDATE mysql.user SET Password=PASSWORD('YourNewPassword') WHERE User='root';
FLUSH PRIVILEGES;
  1. Stop the MySQL Service

    Open Command Prompt and stop the MySQL service:

net stop mysql
  1. Run MySQL with Init File

    Use this command to reset the password:

Make sure the path matches where you saved the file

C:\mysql\bin\mysqld-nt --init-file=D:\\reset.txt
  1. Restart MySQL for Security

    To finalize and secure your MySQL instance, run:

net stop mysql
net start mysql

πŸ’‘ Final Advice

This manual method is powerful but potentially risky if done incorrectly. The best way to avoid this hassle is to store your password securely. You can note it somewhere without explicitly labeling it as a MySQL password.

Avoiding password resets is often just a matter of better personal organization.