Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Monday, October 24, 2022

How to reset MySQL root Password

 I have shown step by step how you can reset the MySQL root password in a windows PC.

  1. Login to your PC as Administrator Mode
  2. 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.
  3. Now create a notepad file with name in your E drive with name mysql-init.txt with 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';


  4. 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"

  5. 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,
    mysqld
    --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini"
    --init-file=E:\mysql-init.txt
  6. Screen shot after executing the above code is shown below.

  7. Now close the command prompt window and start the mysql service.
    The password should have changed now.

No comments:

Post a Comment