Ir al contenido principal

How to Recover/Restore Root's password in MariaDB in Windows

Even though this post is not directly related with the world of data science, it is one of those rare cases when a post is well deserved to be written in case it can save somebody else's life, just like in my case.

A few days ago, I went into a big trouble, because (silly me) in a rare case of overconfidense, I didn't write down a root's passwords for a new DB I was working on, again, silly me.

After review a few pages in Google, I found there was no a very straight forward solution to accomplish this task, so I had to mix and try a few suggested solutions (bibliography below), like this:

1. In Windows, open a command line, using admin privilegies.

2. Navigate through the folder path till you reach MariaDB's bin folder, in my case it was:
C:\Program Files\MariaDB 10.3\bin

3.Stop MySQL service, in case it's still running:
net stop mysql

4.Then move to the data folder:
cd ..
cd data

5. And modify the my.ini file:
notepad my.ini

6. Right below the [mysqld] line, write the following instruction:
skip-grant-tables

7. Save and return to the bin folder:
cd ..
cd bin

8. Now it's time to start the mysql service again:
net start mysql

9. If everything went well, now we can access our MySql Instance as root without needing a password (kind of hackerish don't you think?)

mysql -u root

10. If you were able to access your instance, now select the database to use:

use mysql;

11. Now it's time to redefine the password you are going to use with root:

update user SET PASSWORD=PASSWORD("TheNewPassword") WHERE USER='root';
flush privileges;

12. In some other articles, they recommend to also modify the column authentication_string as follows:

UPDATE user SET `authentication_string` = PASSWORD('TheNewPassword') WHERE `User` = 'root';

13. After that, exit your current session and re edit your my.ini file (at this point I'm pretty sure you know how) to remove the line we added earlier: skip-grant-tables

15. It's time to restart your instance of mariadb:
net stop mysql
net start mysql

16. Finally, try your new password:
mysql -u root -p

Conclusion: This process could be highly risky if you are planning to do it outside of a dev area, so try to avoid the risk, preserving your passwords in a safety way.

Also, as long as the server can be compromised, you should avoid to do this set of steps, while the server is available on network, so your first step should be to disconnect your server of your network while you are working on it (if possible), look for the option  --skip-networking in case you can

Below you will find some interesting links that could give more information about it:

https://stackoverflow.com/questions/23288744/how-to-reset-password-in-mariadb-on-windows
https://stackoverflow.com/questions/1708409/how-to-start-mysql-with-skip-grant-tables
https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
https://robbinespu.github.io/eng/2018/03/29/Reset_mariadb_root_password.html

Comentarios

Entradas populares de este blog

In God we trust, for the rest, bring data

The famous quote has been attributed to W. Edwards Deming, the father of modern quality management. Deming was heavily involved in the economic reconstruction of post World War 2 Japan that saw the country become the world economic powerhouse of the 1960s, 70s and 80s.   Deming had the fundamental philosophy that data measurement and analysis were essential to attaining superior performance in every facet of business. This fundamental principle still holds strong today for any business presence. A significant number of businesses have very little idea on how their business is performing; and more importantly identifying ways to improve it.  This quote by W. Edwards Deming, very concisely explains to us the importance of understanding and interpreting the large volume of data that gets created almost every day by the world.

Modelo de Regresión de Crecimiento Logístico para Estimar el Número de Casos de Covid19 en Guatemala

Hace algunos días compartí un modelo de regresión para  estimar el incremento de casos basados en una proporción lineal. Y aunque este modelo es sencillo de entender y sirve muy bien como introducción didáctica Un modelo que explica mejor el crecimiento de poblaciones como los casos de covid19 es el modelo de regresión exponencial logística. C/(1+A*exp(-B*X)) Este modelo supone dos cosas: 1. Un crecimiento inicial lento pero que con el tiempo se acelera (crecimiento exponencial) 2. Una restricción que obliga a desacelerar el crecimiento hasta que entre dos días no hay diferencia entre el número de casos. (asíntota superior) Estos supuestos le confieren al modelo su clásica forma de "S" Tomando en cuenta los números de casos del día 10 (desde el primer caso) al día 37, se obtiene un modelo muy similar a esto: Pn = 674.7472/(1 + 143.1502*e^(-0.1206*n)) Modelo de Crecimiento Logístico para Contagios de Covid19 en Guatemala (días 10 al 37) Prediccion...