Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recover MySQL root Password

Tags:

mysql

We can reset the mysql password by using the mysqld_safe with --skip-grant-tables option.

  1. Can we reset it without mysql restart?
  2. Can we recover the password instead of Resetting ?
like image 356
Arunjith Avatar asked May 19 '11 05:05

Arunjith


3 Answers

  1. No
  2. No

And there is good reason of both No answers.

  1. You can't just let any non-root user reset your root password without having full admin level access to the MySQL process on that host.
  2. MySQL passwords (like Unix passwords) encryption is 1 way street, they can be reset but cannot be decrypted back.
like image 186
anubhava Avatar answered Nov 26 '22 18:11

anubhava


1) You can update user table in mysql database but only if you still have active connection with enough privileges.

2) You cannot, passwords are not stored, only their hash values, on your login hash of your password is compared to hash stored in mysql and there is no way to find password out of hash other than trying all possible passwords hoping for hash match.

like image 44
piotrm Avatar answered Nov 26 '22 19:11

piotrm


  1. stop mysql service and start it in safe mode
  2. start mysqld --skip-grant-tables
  3. change password normally

see also [1]: http://www.debian-administration.org/articles/442

like image 21
mykey Avatar answered Nov 26 '22 19:11

mykey