昨天同事在問我,他寫一個腳本在透過 mysql client 抓MySQL 上的一些值,但將帳密放在命令列中會報一個告警,我就想起之前在做 Training Lab時也有遇過,這個是要透過檔案引入帳密資訊來避免安全問題
若是直接在命令列中會報一個 “Using a password on the command line interface can be insecure” 的告警.
解決方式是
- 建立一個帳密的參數檔案
# cat mysql_client.config [mysql] user=zabbix password=zabbix
- 在你的 mysql client 參數變更
原格式: mysql -u$username -p$password -h$hostname -e "show databases;" 變更為: mysql --defaults-extra-file=./mysql_client.config -h$hostname -e "show databases;"
你必須 登入 才能發表評論。