消除Warning: Using a password on the command line interface can be insecure的提示

  • 2023-09-19 22:02:37

最近在部署Zabbix时需要用脚本取得一些MySQL的返回参数,需要是numberic格式的,但是调用脚本时总是输出这一句:

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

grep -v也是处理不掉的,很是烦人,在网上翻了翻解决掉,记录于此:

Mysql命令有个如下参数:

--defaults-extra-file=# Read this file after the global files are read.

因此编辑一个password.txt的文件:

[client]
user=leo	
password=leo

脚本中的MySQL连接使用mysql --defaults-extra-file=password.txt的格式,这样就不会报insecure的报错啦。

猜你喜欢