Reset MySQL Root Password in Centos 6

Last updated on Dec 28, 2019 in MySQL, Linux

Resetting the MySQL root password in CentOS 6 is straight-forward.

Stop MySQL Server

sudo /etc/init.d/mysqld stop

Start MySQL Server In Safe Mode

sudo mysqld_safe --skip-grant-tables &

After the server has started, and if looks like it is hanging, press enter and the command prompt should become available again.

Connect to MySQL as Root

mysql -uroot

Change the Root Password

use mysql;
update user set authentication_string=PASSWORD("mypassword") where User='root';
flush privileges;
quit

Restart the MySQL Server

sudo /etc/init.d/mysqld stop
sudo /etc/init.d/mysqld start

Log In To MySQL Normally

mysql -uroot -p

You should now be able to use your new password.