当我在 shellscript 中使用以下命令来使用 mysql 时,
mysql -uUserName -pPassWord DBName
我收到以下警告
Warning: Using a password on the command line interface can be insecure.
我的 shellscript 正在循环运行此命令以在我的表中插入一些数据,因此它在屏幕上连续发出警告,这使得输出完全笨拙,所以我应该做什么来停止从 mysql 打印此警告
最佳答案
如果您的 MySQL 客户端/服务器版本是 5.6.x,则避免出现警告消息的方法是使用 mysql_config_editor 工具:
mysql_config_editor set --login-path=local --host=localhost --user=用户名 --password
然后您可以在 shell 脚本中使用:
mysql --login-path=本地数据库名称
而不是:
mysql -uUserName -pPassWord DBName
关于mysql - 停止来自 mysql 终端的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19900399/