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
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
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
Publicar un comentario