Many people use the MySQL open source relational database server. Mostly for websites, but I’ve also seen it used elsewhere. One problem that I recently ran into with my local development installation is… “what was my root password again?” Aaaggghh!
OK, sorry. Don’t panic; it can be recovered. A quick survey of the internet and I found this very simple and very useful how-to Recover lost MySQL root password mini-HowTo. Is is very well written and easy to follow… but, it only covers the process from a Linux installation. The basic trick here in either platform is to restart your MySQL server in and tell it to skip the grants table. So here is my addition on the Windoze platform.
Recover Your Lost root Password In MySQL (Windows)
- Stop the MySQL server
- You can accomplish this by opening the Services control panel applet, finding the MySQL service listing and clicking the Stop icon.
- Alternately you can open up the command line and type
> net stop MySQL
- Start the MySQL server and skip grants
- Go to the MySQL installation directory and then the \bin directory under that (in the console)
- Type
> mysqld-nt --skip-grant-tables
- Now the MySQL server should be running wide open (ie. every user that logs in has full access)
- Change root password
- Now from another console open the mysql client
- Run the following SQL query replacing the dots (…) with your new password
update user set password = password('.......') where user = 'root' and host='localhost';
- Flush the privileges
flush privileges;
- Quit mysql
quit;
- Stop MySQL server
I tried actually doing a CTRL-C in the console that was running mysqld… but that did not work. So I just opened up the handy-dandy task manager, found the mysqld-nt.exe listing and clicked on it and finally clicked the End Process button - Restart MySQL server normally
- You can accomplish this by opening the Services control panel applet, finding the MySQL service listing and clicking the Start icon.
- Alternately you can open up the command line and type
> net start MySQL
There you have it! All should be well in the world once again and you should now be able to login to MySQL with your new root password. If not… umm… reinstall? lol