How to reset MariaDB root Password
Introduction to MariaDB and its significance
MariaDB is a popular open-source relational database management system that is widely used for its reliability, scalability, and robust features. It is a fork of MySQL and is maintained by the MariaDB Foundation. MariaDB is often preferred by developers and businesses due to its active community support and regular updates. In this article, we will discuss the importance of securing the root password for MariaDB and provide a detailed guide on how to reset it if needed.
Have you found yourself locked out of your MariaDB database due to a forgotten root password? Fear not, as we’re here to guide you through the process of resetting it securely and efficiently.
Understanding the Importance of the MariaDB Root Password
The root password in MariaDB grants the highest level of access to your database system. It’s crucial to keep this password secure and accessible only to authorized individuals. However, if you’ve forgotten or misplaced it, regaining access becomes imperative.
Here is the Step-by-Step Guide to Resetting the MariaDB Root Password
This article describes how to reset the MariaDB root password. You may need to do this, for example, if you have forgotten the password or If you’re getting the below error then it seems the root password is not working or something bad happens to the MySQL root user :
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
To reset the root password for MariaDB, follow these steps:
Step 1: Log in to your account using SSH
You must run the commands in the following steps as the root user. Therefore, you can either log in directly as the root user (which is not recommended for security reasons), or use the su or sudo commands to run the commands as the root user.
Also read – How to change MYSQL root password from CloudStick dashboard
Step 2: Stop the MariaDB server using the command
systemctl stop mariadb.service
Step 3: Restart the MariaDB server with the —skip-grant-tables option. To do this, type the following command:
mysqld_safe –skip-grant-tables –skip-networking &
Make sure you type the ampersand (&) at the end of the command. This runs the command in the background and allows you to type the commands in the following steps.
Running MariaDB with the —skip-grant-tables option enabled is highly insecure, and should only be done for a brief period while you reset the password. The steps below show you how to stop the mysqld_safe server instance safely and start the MariaDB server securely after you have reset the root password.
After running the above command press “Enter” Key > to get the shell again
Step 4: Log into MariaDB using the following command:
mysql -u root
Step 5: At the MariaDB> prompt, type the following commands:
FLUSH PRIVILEGES;
ALTER USER `root`@`localhost` IDENTIFIED VIA mysql_native_password USING PASSWORD(‘new_password’);
SHUTDOWN;
EXIT;
Step 6: Now restart MariaDB
systemctl restart mariadb.service
Best Practices for Managing MariaDB Root Password
1. Regularly Update Passwords
Implement a policy for periodic password updates to mitigate the risk of unauthorized access and enhance overall database security.
2. Utilize Strong Passwords
Enforce the use of strong, complex passwords containing a combination of letters, numbers, and special characters to fortify the security of your MariaDB root account.
3. Limit Access Privileges
Adopt the principle of least privilege by granting access only to necessary individuals and restricting root privileges to authorized administrators.
4. Monitor Database Activity
Implement robust monitoring solutions to track database activity and detect any suspicious behavior or unauthorized access attempts promptly.
5. Backup Regularly
Maintain regular backups of your MariaDB database to safeguard against data loss and facilitate quick recovery in the event of a security incident or system failure.
Conclusion
In conclusion, resetting the MariaDB root password is a straightforward yet crucial task for maintaining the security and integrity of your database system. By following the outlined steps and best practices, you can ensure smooth password management and enhance overall database security.