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';
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
Conclusion
You have Reset MariaDB root password on Centos. I hope will this your helpful. Thank you for reading the DevopsRoles page!