Reset mysql root password

June 27, 2012

To reset the mysql root password follow these steps

1. Stop running mysql instances

# service mysqld stop

1a. If that doesn’t work then kill all running mysql instances

# pkill mysql

1. Stop running mysql instances

# service mysqld stop

2. Start Mysql in safe mode

# mysqld_safe --skip-grant-tables

3. Run these command replacing somepassword with your new password

mysql> update mysql.user set Password=PASSWORD('somepassword') where user='root';
mysql> flush privileges;
mysql> exit;

4. Start mysqld again

# service mysqld stop