Tuesday, July 30, 2013

mysql security using config editor

Here is a sweet tidbit for those who need to do mysql scripts often.
This is great for bash scripts.


mysql_config_editor — MySQL Configuration Utility
The mysql_config_editor utility (available as of MySQL 5.6.6) enables you to store authentication credentials in an encrypted login file named .mylogin.cnf. The file location is the %APPDATA%\MySQL directory on Windows and the current user's home directory on non-Windows systems. The file can be read later by MySQL client programs to obtain authentication credentials for connecting to MySQL Server.
Stores encrypted login information.
mysql_config_editor set --login-path=local --host=localhost --user=fooman --password  

Then just use login-path for your scripts...
 cat some-random-queries.sql | mysql --login-path=local