Warning: Using a password on the command line interface can be insecure.解决办法

关于MySQL中Warning: Using a password on the command line interface can be insecure.解决办法

此问题在zabbix监控mysql的时候出现:

zabbix调用脚本对mysql进行监控,脚本如下:

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`

很明显,这是因为zabbix获取到的值并不是想要的数值类型,而是文本类型,才有上面报错信息。

在agent上执行这条命令结果为:

有一条警告信息,意思是说你在命令行里输入密码是不安全的。

原来这种情况在mysql5.6.X版本中才会出现,解决方法如下:

1.If your MySQL client/server version is a 5.6.x a way to avoid the WARNING message are using the mysql_config_editor tools:

扫描二维码关注公众号,回复: 1957972 查看本文章

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

2.Then you can use in your shell script:

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

instead of:

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

这样设置之后,在脚本里也全部写成这个样子,重启agent后,zabbix web页面就正常了。

猜你喜欢

转载自www.linuxidc.com/Linux/2017-06/144755.htm
今日推荐