In this video I have shown step by step how you can reset the MySQL root password in a windows PC.
- Login to your PC as Administrator Mode
- Stop all MySQL services or APPS that is using MySQL in your PC.
First open the services from windows. Press the Win + R keys on your keyboard, to open the Run window. Then, type ‘services. msc’ and press OK.
Right Click on the MySQL service and Select Stop.
- Now create a notepad file with name in your E drive with name
mysql-init.txtwith below command written that.
ALTER USER 'root'@'localhost' IDENTIFIED BY '<Newpassword>';
I am going to set the password as ‘rootqwer’, So the command will be,
ALTER USER 'root'@'localhost' IDENTIFIED BY 'rootqwer';
- Now open command prompt in Administrator mode and navigate to the bin folder inside the installation directory of MySQL. In my PC its in “C:\Program Files\MySQL\MySQL Server 8.0\bin”. So just typed the below command and hit enter to go inside the bin folder.
cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
- Now execute the below command from the Command Prompt. I have given the path of my.ini file as per my pc. Please update it accordingly to your pc path.
You can locate the my.ini file inside the ProgramData folder inside C drive. Normally the folder might be hidden by default. So enable the option show hidden files and folder in Folder Options to view it. In my pc the path of my.ini is,
C:\ProgramData\MySQL\MySQL Server 8.0
So the command to execute is given below,
--defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini"
- Screen shot after executing the above code is shown below.
- Now close the command prompt window and start the mysql service.
The password should have changed now.