Wednesday, April 26, 2017

Mysql Warning Using a password on the command line interface can be insecure

Advertisements

In new versions of mysql you will get such warning not to specify password in command line. We can resolve this warning by specifying it in file using the utility mysql_config_editor.

Set the credentials using the following command:
mysql_config_editor set --login-path=local --host=localhost --user=username --password

Now you can run the command as:
mysql --login-path=local -e "statement"

Instead of:
mysql -u username -p pass -e "statement"


An alternate way for the older version is to use --defaults-extra-file option.

Create a credentials file my.cnf

cat my.cnf
[mysql]
host = hostname
user = username
password = password

Then when you execute the mysql command specify the path to my.cnf command as

mysql --defaults-extra-file=/path_to/my.cnf

No comments:

Post a Comment

Be nice. That's all.