0

On my Linux system, I always use a configuration file to log in to MySQL servers without having to enter my password every time. These files includes the username and password.

I have to encrypt this configuration file for security reasons. As a consequence of this, MySQL first has to decrypt this file and then read the password. Does MySQL have any APIs to encrypt/decrypt such configuration files? If no, is there any additional way to solve this problem?

1
  • This seems more like a question regarding (the configuration of) MySQL and is therefore off topic. If you focus your question on the second part, this might be more suitable for this site, but the question itself would probably need more detail.
    – Tom K.
    Commented Mar 9, 2018 at 12:46

1 Answer 1

2

It is unclear from your question when you are talking about the MySQL client and when you are talking about the server. While MySQL can accomodate encrypted passwords in the client (using mysql-config-editor) IMHO a better solution is to use an encrypted home dir (or sub-dir) mounted at login time, not least because it provides a means for storing other secrets.

If we're talking about local databases, then you can rely on the SO_PEERCRED for authentication, if we're talking about remote databases then using an ssh tunnel (with a keypair - possibly held on an encrypted home dir) and SO_PEERCRED might be more appropriate.

2
  • Agreed, the best way to connect to a local MySQL database without entering a password is SO_PEERCRED. Commented Mar 9, 2018 at 18:36
  • Thanks for the reply, I have been looking for a utility like "mysql-config-editor" exactly, but I realized that it's for 5.6 and upper versions. Our MySQL version on the system is 5.5 and I will use SO_PEERCRED for the solution. Thanks.
    – korayguney
    Commented Mar 12, 2018 at 7:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .