SoFunction
Updated on 2025-04-25

If you forget MySQL password on Windows, two ways to reset your password

On Windows, if you forget your MySQL password, you can reset the password by:

Method 1: Start MySQL in skip permission verification mode and reset password

Stop MySQL Service

OpenCommand PromptorPowerShell, enter the following command to stop the MySQL service:

net stop mysql

If the service name is notmysql, can be passedService Manager() Check the actual name of the MySQL service and stop the service.

Start MySQL in skip permission verification mode

Open the command prompt and enter the MySQL installation directorybinFolder. For example:

cd C:\Program Files\MySQL\MySQL Server \bin

Start MySQL and skip permission verification (no password is required at this time), and run the following command:

mysqld --skip-grant-tables

This will enable the MySQL server to start in password-free mode.

Reopen a new command prompt window,EnterbinFolder, log in to MySQL:

mysql -u root

Reset password

After logging in, run the following SQL command to reset the root user's password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'New Password';

Or, if an error message appearsALTER USERUnable to use, you can use the following command:

UPDATE  SET authentication_string=PASSWORD('New Password') WHERE User='root';
FLUSH PRIVILEGES;

Exit and restart MySQL service

  • existskip-grant-tablesStop the MySQL service in mode and restart the service to restore normal operation mode.
  • Close all command prompt windows and enter the following command to restart MySQL:
net stop mysql
net start mysql

Method 2: Use temporary configuration of files

Open the MySQL configuration file

  • Go to the MySQL installation directory and findConfiguration file (usually in the MySQL installation directoryDatain folder).
  • exist[mysqld]Add a line in part:
skip-grant-tables

Save and close the file.

  • Restart MySQL service and reset password(Refer to the SQL statement above).
  • After completing password reset, reopenFile, deleteskip-grant-tablesConfigure and restart the MySQL service to ensure secure recovery.

The above method can be used to reset the MySQL password on Windows.

This is the end of this article about the operation of resetting MySQL password on Windows if you forget your MySQL password. For more related content on Windows, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!