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:
- Stopping the database.
- Let's edit the configuration file.
- I'm starting the database.
- We connect to the database.
- Reset privileges.
- Change the password for the root account.
- We stop the database.
- Let's edit the configuration file.
- I'm starting the database.
- 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
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;
6. Change the password for the root account.
mariadb> SET PASSWORD FOR root@'localhost' = PASSWORD('kjs*S&89da');
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.