This post will tell you how to get MySQL passwords in plain text using the .mylogin.cnf file.
Since MySQL 5.6.6, it became possible to store MySQL credentials in an encrypted login path file named .mylogin.cnf, using the mysql_config_editor tool. This is better than in plain text anyway.
Unfortunately (or intentionally), mysql_config_editor doesn’t allow it.
|
1 |
[root@db01 ~]# cat /root/.mylogin.cnf <br><br>????uUd????ٞN??3k??ǘ);??Ѻ0<br> ?'?(??W.???Xܽ<'?C???ha?$<br>?? <br>r(?q`?+[root@db01 ~]# <br>[root@db01 ~]#<br>[root@db01 ~]# mysql_config_editor print --all<br>[client]<br>user = root<br>password = *****<br>[root@db01 ~]# <br> |
I wrote this blog post because I just faced this issue. I needed to get the password out of there. Surprisingly, it is simpler than I thought. While looking for an answer I found that some people created scripts to decrypt it (as it uses the AES-128 ECB algorithm), sometimes getting the MySQL code source or simply using a scripting language.
However, it turns to be very simple. mysql_config_editor does not provide this option, but my_print_defaults does!
|
1 |
[root@db01 ~]# my_print_defaults -s client<br>--user=root<br>--password=Xb_aOh1-R33_,_wPql68<br>[root@db01 ~]#<br> |
my_print_defaults is a standard tool in the MySQL server package. Keep your passwords safe!
Resources
RELATED POSTS