Recover MySQL root Password
开发者_StackOverflowWe can reset the mysql password by using the mysqld_safe
with --skip-grant-tables
option.
- Can we reset it without mysql restart?
- Can we recover the password instead of Resetting ?
- No
- No
And there is good reason of both No answers.
- 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.
- MySQL passwords (like Unix passwords) encryption is 1 way street, they can be reset but cannot be decrypted back.
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.
- stop mysql service and start it in safe mode
- start mysqld --skip-grant-tables
- change password normally
see also [1]: http://www.debian-administration.org/articles/442
This is documented in the Official MySQL documentation here: https://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
I doubt this won't address any and all concerns because you can basically fix any permission or user problem with this method.
精彩评论