Reset MySQL root password on Windows 10

In this article, we are going to see how you can reset the MySQL root password on a Windows machine. If you have forgotten the root password, or you weren't prompted to setup a password while installation, then this will be helpful for you.

I also have a YouTube video on this topic 👇

Follow the steps carefully so that you don't make any mistake.


1. Stop the 'MySQL' service from 'Windows Service Explorer'

1.1. Open Windows Service Explorer

Right click on the Start Menu.

Click on Run.

Type services.msc and click on OK.


1.2. Stop the MySQL service

Search for something that has name as MySQL. I have MySQL80, you can have any number after MySQL depending upon the version. Double-click on it.

Click on the Stop button, and wait for some time for it to get finished.



Don't close this yet, we will be needing this again!

2. Create a text file containing new password in C: drive

2.1. Open Notepad

Right click on the Start Menu.

Click on Run.


Type notepad and click on OK.

2.2. Create and save the text file

Type the following. Replace 1234 by the new password of your choice. 1234 is just for reference.

Save the file on desktop with name as reset.

2.3. Move the text file to C: drive

Move the file reset.txt from desktop to C: drive.







3. Locate the 'my.ini' file on your computer

3.1. Open the ProgramData folder.

Go to C: drive. 


Type the following on the address bar and press Enter.
 

3.2. Locate the 'my.ini' file.

Open the MySQL folder.


Open MySQL Server folder.

Here is the 'my.ini' file we want.

Note down the location of the the file.
In my case, the my.ini file is located at C:\ProgramData\MySQL\MySQL Server 8.0
So, adding \my.ini at the end makes the complete location.
So I have C:\ProgramData\MySQL\MySQL Server 8.0\my.ini as the final location.
You need to note this location somewhere. The name of the folder here in my case is MySQL Server 8.0, but can be different for you. 
I will refer the above highlighted location as ini_file_location. So, further, when I write ini_file_location, I will be referring to the above highlighted my.ini file location.

4. Execute the command using Command Prompt

4.1. Open the installation directory of MySQL Server

Go to C: drive. 

Go to Program Files folder (If you have installed 32-bit version, then go to Program Files (x86)).

Now go to MySQL folder.

Now go to MySQL Server folder. The version can be anything. I have 8.0, yours can be a different one.

Now, go to bin folder.

4.2. Open Command Prompt and execute the command

Click on the address bar, type cmd and press Enter.



A Command Prompt window will be open. Now, type the following command there. Replace the ini_file_location with the location of the my.ini file in your case (Step 3.2)

You can see that I have written C:\ProgramData\MySQL\MySQL Server 8.0\my.ini in place of ini_file_location in above command.


Now, press Enter, and the command prompt window will pause. You'll get an output similar to the one below. Don't close the command prompt window!


4.3. Access MySQL Command Line Client

Now, open MySQL Command Line Client.


Now, enter the new password that you have set.


I had 1234 as my password, so I'll enter that, and if everything is working, you'll be able to access the MySQL with your new password.




5. Restarting MySQL and cleaning up

5.1. Closing all the unnecessary windows.

Close the MySQL Command Line Client.


Close the Command Prompt window.


5.2. Restarting the MySQL Service

Now, go to the Windows Services Explorer from Step 1.1.


Search for MySQL again, and double click on it.


Now, click on Start button to start the service.




Now, close all the remaining windows and open MySQL Command Line Client again to check if the new password is working or not (Step 4.3), just for the sake of completion.


Issues? The universal fix!

If these steps don't work for you, there's no need to worry! 

There's a universal fix for this problem that will work in any circumstances! Just have a look at the video below for the fix.


Conclusion

So, through the help of this article, you are able to reset your MySQL password. If you were not able to follow the steps here, you can watch my YouTube video on this topic.

Thank you for reading till here! Subscribe to my YouTube Channel for amazing videos on computer related topics.

Comment down your thoughts and suggestions in the comment section and if you have something to share with us or if you want to have your article posted on this site, mail us on this mail-id.


Everything Computerized

I'm professionally a programmer and passionately a blogger and YouTuber. My favourite hobby is to share knowledge and teach coding, this is why this Blog and my YouTube channel exists.
You can also subscribe my YouTube channel named "Everything Computerized".
Happy Learning guys! youtube github linkedin instagram email

1 Comments

  1. Too much efforts are put into this blog … taking screenshots to uploading it here on the site. Great work thankyou :)

    ReplyDelete
Previous Post Next Post