How to Reset Your MySQL Password on Windows Server
Oops! You've forgotten or misplaced your root password for MySQL on your Windows Server. Fear not, there is a quick and easy way to get back up and running.
Official documentation for resetting your MySQL root password on Windows Server is provided on the MySQL website, however their guide did not work for me. I researched an alternative method that worked, and I'd like to share it with you today. Follows the steps below.
Steps to reset your MySQL root password
1. Shut down the MySQL service. Open the Windows Services explorer, locate 'MySQL Server', and stop it.*
* Please note that while the MySQL service is stopped, applications that depend on it may not function correctly. If you are operating a commercial server, you may wish to perform these steps during off-peak hours or during a scheduled maintenance period.
2. Open a command window and navigate to your MySQL installation BIN folder. Your installation folder location may vary depending on how it was installed (manual install vs. Web Platform Installer or Wamp). Eg: C:\Program Files\MySQL\MySQL Server 5.5\Bin.
3. Pause MySQL permissions (grants). In the command window, enter the following:
mysqld.exe -u root --skip-grant-tables
After pressing Enter, the command window will pause and not return confirmation of your input; this is expected behavior. Do not close the command prompt window. Minimize it and move to the next step.
3. Open a second command window and once again navigate to your MySQL installation BIN folder. In the command window, enter the following:
mysqld.exe
At this point, MySQL will NOT be asking for login credentials.
4. Set the active database to 'mysql'. Enter the following:
use mysql;
5. Reset your password. Enter the following commands to reset your password:
mysql> UPDATE user SET Password = PASSWORD('NEW-PASSORD') WHERE User = 'root';
Replace NEW-PASSWORD with a strong password. Make a record of it so you don't have to replicate these steps again in the future!
6. Close command windows. Type 'exit;' in the command window you are working in. The minimized command window you were working on previously can simply be closed.
7. Restart the MySQL Service. Open the Windows Services explorer, locate 'MySQL Server', and start it.
If this method did not work for you, official documentation provided by MySQL can be found here. Let me know in the comments below which method worked for you!