rwnx / pynonymizer

A universal tool for translating sensitive production database dumps into anonymized copies.
https://pypi.org/project/pynonymizer/
MIT License
102 stars 38 forks source link

Database host, username and password should be optional for MySQL #108

Closed balcsida closed 2 years ago

balcsida commented 2 years ago

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

rwnx commented 2 years ago

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.

balcsida commented 2 years ago

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.

rwnx commented 2 years ago

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

balcsida commented 2 years ago

Sweeeeeeeet, thank you so much! :bow:

janpeterka commented 1 year ago

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!

rwnx commented 1 year ago

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)

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

janpeterka commented 1 year ago

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