search cancel

How to reset the Root password on MySQL using the command line.


Article ID: 51392


Updated On:


Clarity PPM SaaS Clarity PPM On Premise



Follow these steps to reset the root password for MySQL.


  1. Log on to your system as Administrator.

  2. Stop the MySQL server if it is running.

  3. Create a text file containing the following statements. Replace the password with the password that you want to use.

    UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';

  4. Make sure that the UPDATE and FLUSH statements are on separate lines.

    The UPDATE statement resets the password for all root accounts, and the FLUSH statement tells the server to reload the grant tables into memory so that it notices the password change.

  5. Save the file. For this example, the file will be named C:\mysql-init.txt.

  6. Click on Start -> Run and type 'CMD'.

  7. Navigate to the C:\mysql\bin directory.

  8. Type mysqld --init-file=C:\\mysql-init.txt where "File=" the path of the file you created in step 3.

  9. Stop and restart MySQL service.

  10. Delete the file you created in step 3.

  11. You should now be able to connect to the MySQL server as root using the new password.


Component: PPMENV