MySQL Password Reset

How to Reset MySQL Password on Windows

Reset a forgotten MySQL root password on Windows using a reliable MySQL recovery method with an init file.

MySQL Beginner Updated: May 7, 2026
How to Reset MySQL Password on Windows

Introduction

If you forgot your MySQL root password on Windows, you can reset it by creating a temporary MySQL init file and starting MySQL in recovery mode.

Local Development Only

Only use this process on your own local development machine or server that you control.

Run Programs as Administrator

This guide requires Administrator privileges because Windows normally prevents creating files directly on the C:\ drive and managing MySQL services without elevated access.

STEP 01

Open Notepad as administrator

Open the Windows Start Menu, search for Notepad, right-click it, and select Run as administrator.

Why Administrator privileges are required

Administrator privileges are required so the reset file can be saved directly to the C:\ drive.

STEP 02

Create the MySQL reset file

Paste the SQL password reset command into Notepad.

Replace the placeholder password

Replace new_password_here with the password you want to use for the MySQL root account.

sql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password_here';
STEP 03

Save the reset file

Save the file as mysql-reset.txt directly on the C:\ drive.

Confirm the file path

The final file path should be C:\mysql-reset.txt

STEP 04

Stop the MySQL service

Open Command Prompt as administrator and stop the MySQL service before starting recovery mode.

MySQL service name

Your MySQL service name may be MySQL80, MySQL, or something similar depending on your installation.

cmd
net stop MySQL80
STEP 05

Open the MySQL bin directory

Navigate to the MySQL bin folder so you can run mysqld directly.

Default installation path

The default installation path may vary depending on your MySQL version.

cmd
cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
STEP 06

Start MySQL with the init file

Start MySQL using the real MySQL configuration file and the temporary init file.

What this command does

MySQL will automatically execute the SQL command inside the init file during startup.

cmd
mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --init-file="C:\mysql-reset.txt" --console

Leave the window open

Wait until MySQL finishes starting and processes the init file before continuing.

STEP 07

Stop the temporary MySQL recovery session

After the password reset command has executed successfully, stop the temporary MySQL session.

If MySQL does not stop immediately

Press Ctrl + C inside the Command Prompt window. Sometimes you may need to press Ctrl + C twice before the MySQL process fully stops.

STEP 08

Start MySQL normally

Restart the MySQL service normally so password protection is enabled again.

Use the same service name

Use the same MySQL service name that you stopped earlier in the guide.

cmd
net start MySQL80
STEP 09

Delete the temporary reset file

Remove the reset file so the password reset command cannot run again accidentally.

Important security step

Deleting the reset file prevents the password reset command from running again accidentally in the future.

cmd
del C:\mysql-reset.txt

Password Reset Complete

MySQL should now accept the new root password normally.

Life Craft Alatyr symbol
Part of the Life Craft Network
Life Craft
Body Mind Spirit Craft
Enter the Guild →