在mysql集群中通过shell 脚本获取节点主从状态时如何避免mysql Warning Using a password on the command line interface can be insecure
可以在脚本中使用配置文件来存储MySQL登陆信息,避免在命令行中明文传递密码,从而避免出现警告信息。具体步骤如下:
- 在MySQL服务器上创建一个配置文件,例如/etc/my.cnf,设置MySQL登陆信息:
[client]
user=<username>
password=<password>
- 在脚本中使用mysql命令时,指定该配置文件:
mysql --defaults-file=/etc/my.cnf ...
这样,当脚本执行mysql命令时,就会自动读取配置文件中的登陆信息,不需要在命令行中明文传递密码,也不会出现警告信息。
原文地址: https://www.cveoy.top/t/topic/brF7 著作权归作者所有。请勿转载和采集!