Passwordless command line scripts with MySQL 5.6

I have several command line scripts to MySQL databases for zabbix statistic. These scripts set the password on the command line using the -p option.

With MySQL 5.6, a new warning is displayed every time my scripts run:

mysql notification

 

The way to solve this is to use the new command line tool mysql_config_editor to set up a "login path" which the mysql command line client can then use.

 

$ mysql_config_editor set --login-path=username --host=localhost --user=username –password
 

You will then be asked to enter the password for the user that you've set, 'restore' in this case.

Now, you can log in to mysql on the command line using:

 

$ mysql --login-path=username
 
and note that you didn't need to enter a password!
mysql good

 

It’s very useful for zabbix scripts, where you need to receive only digital value, without any text and other artifacts.