pynonymizer icon indicating copy to clipboard operation
pynonymizer copied to clipboard

Database host, username and password should be optional for MySQL

Open balcsida opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. MySQL client can accept host, port, username, password and other options through option files (.cnf) Additionally, running pynonymizer currently litters the log with the following warning:

mysql: [Warning] Using a password on the command line interface can be insecure.

Describe the solution you'd like I think these settings could be optional instead of required to run pynonymizer

balcsida avatar Feb 17 '22 16:02 balcsida

Sounds logical.

do you know if this behaviour is similar across the other supported DBs (i.e. postgres, mssql)? I'm just thinking about how best to support this.

rwnx avatar Feb 18 '22 11:02 rwnx

Hey @rwnx,

For PostgreSQL, there is password file(.pgpass file in a user's home directory) that can be used similarly.

For MSSQL, the current CLI (which is in preview stage) supports passing these details as environment variables.

balcsida avatar Feb 18 '22 15:02 balcsida

Hi @balcsida !

Late news, but this feature was released in v1.24.0. for MySQL & postgres, you should be able to use the CLI's respective config files to pass credentials to the database.

Check out the changelog for more info: https://github.com/rwnx/pynonymizer/blob/master/CHANGELOG.md#changed

rwnx avatar Sep 07 '22 20:09 rwnx

Sweeeeeeeet, thank you so much! :bow:

balcsida avatar Sep 09 '22 17:09 balcsida

hi, i'm starting with pynonymizer, and I don't know how to use my.cnf for setting user/password.
I have my.cnf file:

[client]
user="user"
password="secret"

but when I run pynonymizer from shell, in same location where my.cnf is located, it's not used. What am I missing? Thanks!

janpeterka avatar Feb 27 '23 15:02 janpeterka

hi @janpeterka !

It's hard to diagnose from the info here, but here's what i'd look into first:

we don't load my.cnf directly, we rely on the mysql client's behaviour. I don't think it loads data from the same directory. I think it loads from a list of paths, e.g. $HOME/my.cnf.

File Name Purpose
/etc/my.cnf Global options
/etc/mysql/my.cnf Global options
SYSCONFDIR/my.cnf Global options
$MYSQL_HOME/my.cnf Server-specific options (server only)
defaults-extra-file The file specified with --defaults-extra-file, if any
~/.my.cnf User-specific options
~/.mylogin.cnf User-specific login path options (clients only)
DATADIR/mysqld-auto.cnf System variables persisted with SET PERSIST or SET PERSIST_ONLY (server only)
  • Where is your my.cnf stored?
  • are you passing any options that might interfere with this?

If you're still having trouble with this, I think you should open a new issue and we'll do a deeper investigation.

rwnx avatar Feb 27 '23 19:02 rwnx

Hi, thanks so much! I never played with MySQL configuration much, so I didn't realize this :)

janpeterka avatar Feb 27 '23 21:02 janpeterka