关于mysql中Warning: Using a password on the command line interface can be insecure.解决办法
此问题在zabbix监控mysql的时候出现:
zabbix调用脚本对mysql进行监控,脚本如下:
1
|
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:
1
|
mysql_config_editor
set
--login-path=
local
--host=localhost --user=username --password
|
2.Then you can use in your shell script:
1
|
mysql --login-path=
local
-e
"statement"
|
instead of:
1
|
mysql -u username -p pass -e
"statement"
|
这样设置之后,在脚本里也全部写成这个样子,重启agent后,zabbix web页面就正常了。
本文转自 青苗飞扬 51CTO博客,原文链接:http://blog.51cto.com/qingmiao/1911535