用mysql从内部终端燮preSS警告信息,但密码写在bash脚本 [英] Suppress warning messages using mysql from within Terminal, but password written in bash script

查看:206
本文介绍了用mysql从内部终端燮preSS警告信息,但密码写在bash脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图在终端运行在MySQL以下命令:

When I tried running the following command on MySQL from within Terminal:

mysql -u $user -p$password -e "statement"

执行正常工作,但它总是发出警告:

The execution works as expected, but it always issues a warning:

警告:在命令行界面上使用密码可以是不安全的

不过,我要进行上面的使用环境变量( $密码),存储我的密码的说法,因为我想在bash脚本反复运行命令在终端,我绝对不喜欢在一个脚本等待提示显示出来,并迫使我输入我的密码50或100倍的想法。因此,这里是我的问题:

However, I have to conduct the statement above using an environment variable ($password) that stores my password, because I want to run the command iteratively in bash script from within Terminal, and I definitely don't like the idea of waiting a prompt showing up and forcing me to input my password 50 or 100 times in a single script. So here's my question:


  • 这是向供应preSS警告是否可行?该命令工作正常,我说,但窗口变成pretty凌乱,当我遍历并运行命令50倍或100倍。

  • Is it feasible to suppress the warning? The command works properly as I stated, but the window becomes pretty messy when I loop over and run the command 50 or 100 times.

我应该听从警告信息,不要在我的剧本写我的密码?如果是这样的话,那么我要在我的密码每次都提示力量我这样做键入?

Should I obey the warning message and do NOT write my password in my script? If that's the case, then do I have to type in my password every time the prompt forces me to do so?

运行男人的mysql 没有帮助,只是说

- 显示的警告结果
  如果有任何需要每个语句后有因由的警告。此选项适用于交互式和批处理模式。

--show-warnings
Cause warnings to be shown after each statement if there are any. This option applies to interactive and batch mode.

和没有提及如何关闭功能,如果我不缺少的东西。

and mentions nothing about how to turn off the functionality, if I'm not missing something.

我在OS X 10.9.1小牛和自制软件使用MySQL 5.6。

I'm on OS X 10.9.1 Mavericks and use MySQL 5.6 from homebrew.

推荐答案

如果你的MySQL客户端/服务器版本是一个5.6.x的方式来避免该警告消息正在使用的 mysql_config_editor工具:

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:

mysql_config_editor set --login-path=local --host=localhost --user=username --password

然后你就可以在你的shell脚本中使用:

Then you can use in your shell script:

mysql --login-path=local  -e "statement"

而不是:

mysql -u username -p pass -e "statement"

这篇关于用mysql从内部终端燮preSS警告信息,但密码写在bash脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆