How to Reset MariaDB root password on Centos: A Simple Guide

Introduction

MariaDB is free and Open-source. It is the famous fork of the MySQL database. In this tutorial, How to Reset MariaDB root password. Forgetting the root password of your MariaDB database can be a frustrating experience, especially when you need to make critical updates or changes.

However, resetting the MariaDB root password on CentOS is a manageable task if you follow the right steps. This guide will take you through a straightforward, step-by-step process to reset your MariaDB root password, ensuring you regain access to your database quickly and securely. Let’s get started and resolve this issue efficiently.

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';
mysql> FLUSH PRIVILEGES;

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';
mysql> FLUSH PRIVILEGES;

For MySQL 5.7.5 and earlier or MariaDB 10.1.20 and earlier:

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

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
Reset MariaDB root password on Centos

Conclusion

You have Reset MariaDB root password on Centos. By following the steps outlined in this guide, you should now have successfully reset your password and regained control over your MariaDB database. Remember, maintaining secure and up-to-date records of your credentials is essential to avoid similar issues in the future. If you encounter any problems or need further assistance, don’t hesitate to reach out for support. I hope will this your helpful. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology, especially Devops Skill such as Docker, vagrant, git, and so forth. I like open-sources, so I created DevopsRoles.com to share the knowledge I have acquired. 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.