Reset MariaDB Root user Password

Today, we faced a problem where our client application was not working because of the database connection issue. I have checked and found that their credentials were incorrect. As per the client, this was that same credentials which their application was using.

So, To resolve the problem, we decided to reset the root user password with the same value.

Lets reset the root password:

1: First stop your MariaDB database.
1sudo systemctl stop mariadb
2: Restart your database with safe mode. (Now it will not ask the password)
1sudo mysqld_safe --skip-grant-tables &
3: Now Reconnect MariaDB database without password
1mysql -u root
4: connect to mysql database
1use mysql;
5: check user table
1select * from user;

Note: Check the schema very carefully. Please replace the column name, if it's not matching the below command.

6: Now change the password. Replace my-password with your strong password.
1 update user SET PASSWORD=PASSWORD("my-password") WHERE USER='root';
7: Flush the privileges:
1 flush privileges;
8: Now come out from the database:
1 exit
9: Lastly, start MariaDB database:
1sudo systemctl start mariadb


If you get an error while starting the MariaDB database. Please check if mysql service is running or not. You can use top command to check the same.

You have to stop all the old mysql process by using below command:

1pkill mysql

Now, try to restart the database. :smile:

I :heart: AWS! :smile: Enjoy