How to Reset the root Password of MariaDB Database on Ubuntu
In the management of a MariaDB database, the root account is the superuser account that has full access rights to the database system. However, users may sometimes encounter difficulty accessing the root account if they forget the password. In situations like this, we need to reset the MariaDB root password to regain access to the database. Here is a step-by-step guide to resetting the MariaDB root password.
1. Stop the MariaDB service.
1 | sudo systemctl stop mariadb |
2. Run MariaDB without loading access control tables and networking.
1 | sudo mysqld_safe --skip-grant-tables --skip-networking & |
3. Log in to MariaDB.
1 | sudo mariadb -u root |
4. Change the root password using the ALTER command.
1 2 3 4 | FLUSH PRIVILEGES; ALTER USER root@localhost IDENTIFIED BY 'new_password'; FLUSH PRIVILEGES; exit |
5. Stop MariaDB.
1 | sudo mysqladmin -u root -p shutdown |
6. Start the MariaDB service again.
1 | sudo systemctl start mariadb |
7. Test the new password by logging in to MariaDB.
1 | sudo mariadb -u root -p |
Congratulations, you have successfully reset the MariaDB root password.
If you found this article helpful and would like to support my work, consider making a donation through PayPal. Your support helps me continue creating useful content and tutorials. Thank you!
Donate via PayPal: https://paypal.me/musaamin