How to reset the Root password on MySQL using the command line.
Article ID: 51392
Clarity PPM SaaS
Clarity PPM On Premise
Follow these steps to reset the root password for MySQL.
- Log on to your system as Administrator.
- Stop the MySQL server if it is running.
- 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';
- 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.
- Save the file. For this example, the file will be named C:\mysql-init.txt.
- Click on Start -> Run and type 'CMD'.
- Navigate to the C:\mysql\bin directory.
- Type mysqld --init-file=C:\\mysql-init.txt where "File=" the path of the file you created in step 3.
- Stop and restart MySQL service.
- Delete the file you created in step 3.
- You should now be able to connect to the MySQL server as root using the new password.