Reset MariaDB root password on Centos

MariaDB is free and Open-source. It is the famous fork of the MySQL database. In this tutorial, How to Reset MariaDB root password.

Check the version of the MariaDB server.

mysql --version

How to reset MariaDB root password

Step by step to reset your MySQL/MariaDB root password.

Stop MySQL/MairaDB service

For MySQL:

sudo systemctl stop mysql

For MariaDB:

sudo systemctl stop mariadb

Start the database server without loading the grant tables

sudo mysqld_safe --skip-grant-tables &

Log in to the MySQL shell

mysql -u root

Set a new root password

For MySQL 5.7.6 and later or MariaDB 10.1.20 and later

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MY_NEW_PASSWORD';

If ALTER USER statement doesn’t work for you, Try the command below

mysql> USE mysql;
mysql> UPDATE user SET password=PASSWORD('MY_NEW_PASSWORD') WHERE User='root' AND Host = 'localhost';

For MySQL 5.7.5 and earlier or MariaDB 10.1.20 and earlier:

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MY_NEW_PASSWORD');

Stop and Start MySQL/MariaDB

For MySQL:

sudo systemctl stop mysql
sudo systemctl start mysql

For MariaDB:

sudo systemctl stop mariadb
sudo systemctl start mariadb

Verify the password

mysql -u root -p


You have Reset MariaDB root password on Centos. I hope will this your helpful. Thank you for reading the DevopsRoles page!


About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.