Retrieve Lost Password in MYSQL

Sometime, we forget the root password for mysql. It happened to me once in my company. The previous developer left and didn’t document where to look for passwords. Well, it is possible for the root user of the system to reset it anyway…

First shutdown mysql,

/etc/init.d/mysql stop

then

mysqld –skip-grant-tables –u root
mysql -u root
mysql> use mysql;
mysql> UPDATE user SET Password = PASSWORD(‘newpass’) WHERE User = ‘root’;
mysql> FLUSH PRIVILEGES;

If there is an error about certain ip cannot access the db, grant permission like so:

GRANT ALL ON *.* TO ‘someuser’@’somehost’;

make sure the host name is correct.

Like it.? Share it:
Tags:

Comments are closed.