Reset MySQL Root Password in Centos 7

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

Stop MySQL Server

sudo systemctl stop mysqld

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 systemctl stop mysqld
sudo systemctl start mysqld

Log In To MySQL Normally

mysql -uroot -p

You should now be able to use your new password.


Did you find this tutorial helpful? Please share:

What we do?

We do full-stack development. We develop web applications and mobile apps ranging from industrial-grade ERP systems to online auction websites. We use the most modern programming and project management techniques to produce a high-value product in time.

See References

The Stack

Read more

Full Stack development

We develop web applications and mobile apps ranging from industrial-grade ERP systems to online auction websites. We use the most modern programming and project management techniques to produce a high-value product in time.

See References