X
    Categories Tutorials

How to Reset MariaDB Root Password

We will show you How to Reset MariaDB Root Password. Resetting your MariaDB root password on your Linux server is an easy task if you carefully follow our tutorial below.  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.

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 &
[1] 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

If you use one of our MariaDB Optimized Hosting, you don’t have to reset your MariaDB root password, simply ask our admins, sit back and relax. Our admins will reset MariaDB root password for you immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

admin :

View Comments (6)