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.
sudo systemctl stop mariadb
2. Run MariaDB without loading access control tables and networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
3. Log in to MariaDB.
sudo mariadb -u root
4. Change the root password using the ALTER command.
ALTER USER root@localhost IDENTIFIED BY 'new_password';
5. Stop MariaDB.
sudo mysqladmin -u root -p shutdown
6. Start the MariaDB service again.
sudo systemctl start mariadb
7. Test the new password by logging in to MariaDB.
sudo mariadb -u root -p
Congratulations, you have successfully reset the MariaDB root password.