...
Line
Skip to main content
< All Topics
Print

How to Reset MySQL Root Password in Windows

Step 1: Log in as Administrator

Log in to the Windows machine as an administrator. Administrative access ensures that you have the necessary rights to modify system-level settings.

Step 2: Stop MySQL server

  1. Press Win+R (hold the Windows/Super key, and press r).

2. In the Run box, type services.msc and press Enter

3. Scroll down the list of services to find the MySQL service. Right-click the entry and select Stop

Step 3: Create Password File

The password file is a .txt document containing the new password you want to use.

Follow the steps below:

1. Press the Windows key and search for Notepad. Press Enter to open the app.

2. Add the following line to the text file

  • Make sure to keep the quote marks and semicolon. Replace NewPassword with the password of your choice.
  • The localhost string makes the password change on your local system. If you’re changing the password on a system over the network, substitute localhost with the appropriate hostname.

Save the file to the root of your hard drive (C: ). The filename should be mysql-init.txt.

Step 4: Open Command Prompt

  1. Press the Windows key and type cmd.
  2. From the search results, select the Run as administrator option to open Command Prompt as administrator.

Step 5: Add New Parameters and Restart Server

  1. Navigate to the MySQL directory using the command prompt:

If you have a different MySQL version, make sure to use that version in the command.

  1. Depending on how you installed MySQL, there are two ways to restart the server with the new parameters:
  2. If you installed MySQL using the ZIP arc67hive

Run the following command

Note that there are two slashes after the C: prompt.

  • If you installed MySQL using the MySQL Installation Wizard

You must specify a –defaults-file option in the command, followed by the path to the configuration file. Find the file path by right-clicking the MySQL service in the services list and selecting Properties:

The file path is listed in the Path to executable section. Copy the file path and use it in the command below, but make sure to use double slashes (\\) instead of single (\) in the path:

3. Restart the MySQL service from the Services list. Right-click the MySQL service and select Start.

 

Step 6: Clean up

Now, log into your MySQL server as root using the new password. Once MySQL launches and you’ve confirmed the password change, delete the C:\mysql-init.txt file.

Credit : How to Reset/Change MySQL Root Password on Linux or Windows (phoenixnap.com)

Messenger
Seraphinite AcceleratorOptimized by Seraphinite Accelerator
Turns on site high speed to be attractive for people and search engines.