We’ll show you, how to reset MariaDB root password. Did you forget your MariaDB root password? Do not worry, there is an easy way to reset your password on MariaDB in less than 5 minutes. Please note that you need to have root access to your server to be able to change the password of MariaDB. Resetting your MariaDB root password on your Linux server is an easy task if you carefully follow our tutorial below.
1. Login to your server via SSH
Log in to your Linux virtual server via SSH as user root and stop the running MariaDB daemon:
# service mysql stop Shutting down MySQL. SUCCESS!
2. Start MariaDB in Safe Mode
Start MariaDB in safe mode with ‘skip-grant-tables’ option. Grant tables store the passwords, so using this option you can login to MariaDB without password:
# mysqld_safe --skip-grant-tables &  14721 131108 19:06:41 mysqld_safe Logging to '/var/lib/mysql/domain.com.err'. 131108 19:06:41 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
3. Login to MariaDB
Now, you are able to log in to MariaDB without a password:
# mysql -u root Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 1 Server version: 5.5.33a-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 >
4. Reset MariaDB Root Password
Once you are logged in, you can reset your MariaDB root password by executing the following SQL commands:
MariaDB [(none)]> use mysql; MariaDB [(none)]> update user set password=PASSWORD("NEWPASSWORD") where User='root';
Don’t forget to replace ‘NEWPASSWORD’ with your actual password.
5. Flush privileges
Now, flush the privileges and exit from the MariaDB server:
MariaDB > flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit; Bye
6. Restart MariaDB
Finally, restart your MariaDB server:
# service mysql restart
Done. Your old MariaDB root password is changed and you have a new password.
Now you can log in to MariaDB using the new password:
# mysql -u root -p
PS. If you liked this, on how to reset MariaDB root password, post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.