How to reset MariaDB root password

  • Last update: Apr 3, 2024
  • Views: 36
  • Author: Admin
How to reset MariaDB root password

Hello colleagues.

In today's article, I will tell you how to reset the super root password in MariaDB. I'm sure almost all of you have had cases when you lost the password from the root account. I looked at many articles on this topic on the Internet, but could not find adequate information on how to do this.

 

Article content:

  1. Stopping the database.
  2. Let's edit the configuration file.
  3. I'm starting the database.
  4. We connect to the database.
  5. Reset privileges.
  6. Change the password for the root account.
  7. We stop the database.
  8. Let's edit the configuration file.
  9. I'm starting the database.
  10. Results.

 

1. Stopping the database.

Before starting work, we need to stop the database.

$. service mariadb stop.


 

2. Let's edit the configuration file.

After stopping the database data, we need to add two parameters to the configuration file.

$. vim /etc/my.cnf.d/server.cnf

mariadb_reset_root_password

We have added two required parameters. skip-networking and skip-grant-tables


 

3. I'm starting the database.

After we have corrected the configuration file, we can start the database.

$. service mariadb start


 

4. We connect to the database.

$. mysql -u root -p

You will be allowed into the database without a password.


 

5. Reset privileges.

We need to perform a privilege reset operation to tell the server to reload the privilege tables.

mariadb> FLUSH PRIVILEGES;

mariadb_reset_root_password


 

6. Change the password for the root account.

mariadb> SET PASSWORD FOR root@'localhost' = PASSWORD('kjs*S&89da');

mariadb_reset_root_password


 

7. We stop the database.

$. service mariadb stop


 

8. Let's edit the configuration file.

After we changed the password for the root account, we now need to remove the two parameters that we added.

$. vim /etc/my.cnf.d/server.cnf

Delete skip-grant-tables and skip-networking, save and close.


 

9. I'm starting the database.

$. service mariadb start


 

10. Results.

We have successfully changed the password of the root account. If you do everything according to the steps that I have indicated, then you will succeed.


 

Thank you all, I hope my article was of some help to you.

 

SIMILAR ARTICLES