Howto recovery mysql root password

Five steps to recovery root password of mysql server

  1. Stop mysql server

# /etc/init.d/mysql stop

2. Start mysql server without password

# mysqld_safe –skip-grant-tables &

3. Connect to mysql server using mysql client

# mysql -u root

the output will be something like this:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


mysql>


4. Configure new password for root user

mysql> use mysql;
mysql> update user set password=PASSWORD(“YOUR_PASSWORD_HERE”) where User=’root’;
mysql> flush privileges;
mysql> quit;

5. Stop mysql services.

# ps ax | grep mysql

* tip: first stop -> mysqld_safe

Example :

# kill -9 4456
# kill -9 4567

and then

# /etc/init.d/mysql start

 

This entry was posted in Information and tagged , , . Bookmark the permalink.