In this world without frontiers, who needs Gates and Windows

Tuesday, February 07, 2012

Recover mysql password

Hi my name is Bernardo, and today i am going to teach you, how to recover your mysql password.
This is funny, cause i've just reset my password, LOL, i forgot my mysql password, but thats another story, lets get to work

1.- The first step is: Stop the server
This can be done by typing in the console this instruction:

service mysqld stop

2.- The second step: Start mysql in safe mode
This is important, cause in this way we are able to change the password, with this we are leaving the mysql console open to any connection without a passwd, remember to put the "&" after the line, cause this leaves the process in second plane.

mysqld_safe --skip-grant-tables --skip-networking&

3.- The third step: Conect to mysql server
At this moment(after typing the below instruction), mysql should'nt ask for a password, and you'll have full access to the mysql server
mysql -u root

4.- The fourth step: Change the password

You need to modify the table "User" and set the new value, in this case, your new password, if you look at the line, we are only typing a query for an update, where the user is "root"
UPDATE user SET password=PASSWORD('new_pass') WHERE user='root';
5.-The fifth step: Just restart the service
If every step before was ok, we only need to restart mysql service, by typing this instruction
service mysqld restart

So, thats it, easy, dont you think!!!
If you have any question, you can leave a coment, See you guys!!!

No comments: