Database

Fix : Mysql Warning Using a Password on The Command Line Interface Can be Insecure

If you are using command line interface to access your Mysql server and getting “Mysql Warning Using a Password on The Command Line Interface Can be Insecure“. You can resolve this warning by specifying it in the file using the utility mysql_config_editor.

In this article I will show you how to resolve this issue.

Fix : Mysql Warning Using a Password Message

Follow the below command to set the credentials using the following command:

mysql_config_editor set --login-path=local --host=localhost --user=username --password

You can run the below command as:

mysql --login-path=local -e "statement"

Instead of:

mysql -u username -p pass -e "statement"

Alternately for older version is to use –defaults-extra-file option.

Create my.cnf file with credentials in user’s home directory or you can also define different path instead of home directory.

# vim /path_to/.my.cnf
[mysql]
host = hostname
user = username
password = password

Save and close file. Now run the mysql command with specifying the my.cnf file. For example:

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

Guys, This problem also occurs when you setup Zabbix to monitor your MySQL Database, Basically this  warning will prompt when you use mysql 5.6.x or higher version.

Mysql Warning Msg

Mysql Warning Msg

 

 

 

Normally, Zabbix call this script to connect and monitor your MySQL DB.

result=`/usr/local/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Com_select"|cut -d"|" -f3`

Solution for this issue :

You can avoid this version in MySQL server version 5.6.x using mysql_config_editor.

If your MySQL client/server version is a 5.6.x a way to avoid the WARNING message are using the mysql_config_editor tool as I mentioned above this tutorial. For example :

mysql_config_editor set --login-path=local --host=localhost --user=username --password

Lets run the below command:

mysql --login-path=local -e "statement"

Now restart your zabbix Agent.

# systemctl restart zabbix-agent

Enjoy your warning disappeared after restarting Zabbix Agent.

You can follow this link to more know more about mysql_config_editor.

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment