mysql_config_editor
This utility enables you to store authentication credentials in an obfuscated login path file named ~/.mylogin.cnf.Â
On Windows the file is in %APPDATA%\MySQLThis is useful for connecting to the database securely from within scripts etc.
Check
To see the contents of mylogin.cnf...
Password is obfuscated in the output from this commandmysql_config_editor print --all
Create
mysql_config_editor set --user=root --password
This will create an entry under the default [client] login-pathTo use the stored password...
mysql
Note that, when storing the root password in this way, MySQL is only as secure as your OS login (i.e. if your OS account is breached, then the database is too).login-path
To store a password that could be used by a scheduled mysqlbackup...
mysql_config_editor set --login-path=mysqlbackup --host=myserver --user=mysqlbackup --password
You will be prompted for the passwordlogin_path is an arbitrary label that you will pass when you later try to connecthost and user must match with an existing MySQL userNote that login-paths of 'mysql' and 'client' are special cases that are always read when trying to connect irrespective of whether you pass log-path when connecting.To use the stored password...
mysql --login-path=mysqlbackup
mysqlbackup --login-path=mysqlbackup --backup-dir=/mysql/backup/FULL --socket=/mysql/mysql.sock --compress backup
Delete
To delete an entry...
mysql_config_editor delete --login-path=mysqlbackup
To clear all entries...
mysql_config_editor reset