How to Recover MySQL root Password in Linux?

DeeKay September 20, 2011 at 11:30 pm · Linux

To Recover MySQL root password in linux follow below steps –


First Stop mysql service.
# /etc/init.d/mysqld stop

Start MySQL server without password:
# mysqld_safe   – -skip-grant-tables &

Connect to mysql server using mysql client:
# mysql -u root

Setup new MySQL root user password
mysql> use mysql;
mysql> update user set password=PASSWORD(“NEW-PASSWORD”) where User=’root’;
mysql> flush privileges;
mysql> quit

Finally restart MySQL Server and test it.
# /etc/init.d/mysqld restart

# mysql -u root -p