Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to read from another config file in the DSN #1026

Open
guillemj opened this issue Nov 6, 2019 · 2 comments
Open

Add support to read from another config file in the DSN #1026

guillemj opened this issue Nov 6, 2019 · 2 comments

Comments

@guillemj
Copy link

guillemj commented Nov 6, 2019

There is no support for reading a mysql configuration file as specified in the DSN. This is supported in other language bindings as read_default_file (or mysql_read_default_file). See https://bugs.mysql.com/bug.php?id=57081 for various examples. This is also supported as part of the C client library https://dev.mysql.com/doc/refman/8.0/en/mysql-options.html with its MYSQL_READ_DEFAULT_FILE option.

This makes it possible to specify for example the user and password (and host and port) in a central place, with tight file permissions instead of having to write these in places that are less desirable. In our case, we need to write the user/pass in the telegraf.conf file, and restrict the permissions, and duplicate the credentials that otherwise would be centralized in a single file.

@dolmen
Copy link
Contributor

dolmen commented Jun 1, 2020

This can be implemented by writing another sql.Driver that wraps the the original driver.

As a demonstration, see my own driver github.com/dolmen-go/mylogin-driver that reads host/port/user/password from ~/.mylogin.cnf.

@guillemj
Copy link
Author

guillemj commented Jun 1, 2020

That would require patching/forking any upstream that uses this package to use something else, which seems rather undesirable. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants