Have you forgotten MariaDB root password? You don’t know how to recover it. Not to worry, this tutorial will help you to reset MariaDB root password on Linux system.
Le’ts follow step by step tutorial to reset MariaDB root password on your Linux systems.
Step 1 – Stop MariaDB Service
First of all, you need to stop MariaDB service on your system. You can do this using the following command.
SysVinit users -$ sudo service mysql stop Systemd users -$ sudo systemctl stop mysql.service
Step 2 – Start MariaDB in Safe Mode
Now start your MariaDB service in safe mode using skip grant and run this command in the background.
# mysqld_safe --skip-grant-tables &  6218 140118 22:27:09 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'. 140118 22:27:09 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Step 3 – Login to MariaDB and Change Password
After starting MariaDB in safe more connect to MariaDB with root user and without any password. After that run following command to change the root user password.
# mysql -u root
MariaDB [(none)]> use mysql;
MariaDB [mysql]> UPDATE user SET password=PASSWORD("secret") WHERE User='root';
MariaDB [mysql]> FLUSH PRIVILEGES;
MariaDB [mysql]> quit;
Step 4 – Stop and Start MariaDB
After successfully changing the password, stop the MariaDB service and start it again in normal mode using following commands.
SysVinit users -# service mysql stop # service mysql start Systemd users -$ sudo systemctl stop mysql.service $ sudo systemctl start mysql.service
Step 5 – Login with New Password
You have now new root user password for your MariaDB instance. Login to MariaDB instance to verify the new password.
# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 1 Server version: 5.5.34-MariaDB MariaDB Server Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. MariaDB [(none)]>