Resetting MySQL root password in Windows

This tutorial describes how to reset the MySQL root user password if the root password is forgotten. The procedure in windows involves creating a new file which contains a query to UPDATE the MySQL root user’s password from the table named ‘user’ and then start the MySQL process again. Before starting check whether MySQL is running as a service or as a process. To check this got to start -> run or [windows] + R and type services.msc. If you find a service named MySQL or something similar to wampmysql then MySQL is running as a service right click it and stop it. Else open task manager and locate a process named mysqld and “End” the process. If you’re using Linux read this article.

The defaults-file contains the configuration for MySQL if you don’t know where this file is see the MySQL service properties window. The init-file option is the path to the queries file created in the previous step. The console option displays the output in the command line.

Reset the MySQL root user password

After you see the above screen close the command line and start the MySQL service or process. Try connecting using the updated root password through the command line from inside the bin folder.

mysql.exe -u root -p

You’ll be prompted for the new password enter it and login. To change the MySQL root password type these queries.

Replace secure_password with a new very very secure password. Do the necessary changes in your scripts. After the completion of all the steps remove the .sql file containing queries to change the MySQL root password immediately.