patternsqlMinor
credentials file for running mysql related jobs via script?
Viewed 0 times
scriptfilerelatedcredentialsmysqlrunningjobsforvia
Problem
Is there a method to point mysql to a credentials file instead of entering account passwords directly in scripts?
Example:
/etc/mysql_creds
Example:
mysqldump --opt --credfile /etc/mysql_creds mydatabase > output.sql/etc/mysql_creds
username=myuser
password=ToPsEcReTSolution
It would be better to store the credentials in a config file, and load them as an extra-defaults file:
The config file is the same format as /etc/my.cnf or ~/.my.cnf
MySQL 5.6 also introduces encrypted storage of credentials. You can set up an encrypted file ~/.mylogin.cnf:
Then you can dump using that login path
$ mysqldump --defaults-extra-file=mycred.cnf ...The config file is the same format as /etc/my.cnf or ~/.my.cnf
$ cat mycred.cnf
[mysqldump]
user = myuser
password = xyzzyMySQL 5.6 also introduces encrypted storage of credentials. You can set up an encrypted file ~/.mylogin.cnf:
$ mysql_config_editor set --login-path=dump --host=localhost --user=root --password
Enter password:Then you can dump using that login path
$ mysqldump --login-path=dump ...Code Snippets
$ mysqldump --defaults-extra-file=mycred.cnf ...$ cat mycred.cnf
[mysqldump]
user = myuser
password = xyzzy$ mysql_config_editor set --login-path=dump --host=localhost --user=root --password
Enter password:$ mysqldump --login-path=dump ...Context
StackExchange Database Administrators Q#72417, answer score: 6
Revisions (0)
No revisions yet.