Note: There is nothing new in the following post. Just some redundant info that can be found on web.
I’m from a project which calls itself a research lab. I’ve never done a serious research till I came out of the project to help a teammate who was doing some other project.
When I was in lab, I use to suggest my teamies to use MySQL rather than heavier databases from MS or Oracle. MySQL is free, lighter and PHP’s best friend. We have installed MySQL in almost every desktop and every server in our control. In most of our Projects, we saved usernames and passwords in the MySQL database. What about MySQL’s password ?
I remember the cases where my teamies forgot their password and ended up in reinstalling MySQL. Well, that’s not at the solution for the problem. Very simple solution is to skip authorization checks and starting MySQL and resetting the password. Login as Administrator or root into the machine and then
- If MySQL is running, stop the server
- Command in Linux : $ killall -9 mysqld
- Command in Windows : C:\net stop mysql
- Start the MySQL server using the following command
- Linux : /path/to/mysql/bin/safe_mysqld — skip-grant-tables &
- Windows : C:\path\to\mysql\bin> mysqld-nt — skip-grant-tables
- Now, you don’t need a password to login to MySQL as root
- mysql -u root
- Mysql> use mysql;
- Mysql> update user set password = password ( “newPassword”) where user = “root”;
- Mysql> flush privileges;
- Mysql> exit
- Restart MySQL server using mysqladmin command
- mysqladmin -u root shutdown -p
- Start MySQL normally
Out of “What the hell is my password ?” to “Hope, I wont forget my new password”