如何在 MySQL 5.6 命令行客户端中使用 --verbose 标志?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29959112/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use the --verbose flag in the MySQL 5.6 command line client?
提问by HB-
Going by the list of flags here, with the line at the top about usage: Usage: mysql [OPTIONS] [database]
.
通过这里的标志列表,顶部的关于用法的行:Usage: mysql [OPTIONS] [database]
。
I am running Windows 8; my table is "contact"; I want to create a tee file for source C:/myfile.sql
with the verbose option on.
我正在运行 Windows 8;我的表是“联系方式”;我想创建一个source C:/myfile.sql
带有详细选项的 tee 文件。
I have tried mysql -v contact
, -v contact
, --verbose contact
, --verbose source C:/myfile.sql
, and various others.
我已经试过mysql -v contact
,-v contact
,--verbose contact
,--verbose source C:/myfile.sql
,和各种人。
EDIT: adding screenshot of where I'm trying to run this, in case it helps.
回答by Barranka
The correct syntax for a verbose interactive session is:
详细交互式会话的正确语法是:
c:\> mysql -u yourUser -p -v yourDatabase
This will launch an interactive session (prompting you for password), and set yourDatabase
as the default database for the session.
这将启动一个交互式会话(提示您输入密码),并设置yourDatabase
为会话的默认数据库。
Once in this interactive session, issue a tee
command:
进入此交互式会话后,发出tee
命令:
mysql> tee c:/temp/my.out
And now you can source your script:
现在你可以获取你的脚本:
mysql> source c:/myfile.sql
Of course, you can avoid all this pain by simply putting this in your command prompt:
当然,您可以通过简单地将其放在命令提示符中来避免所有这些痛苦:
c:\> mysql -u yourUser -pYourPassword -v yourDatabase < myfile.sql > my.out
This will:
这会:
- Push the contents of
myfile.sql
to an "interactive" mysql session... that's essentially a batch process - Redirect all contents of the batch process to
my.out
- 将 的内容推
myfile.sql
送到“交互式”mysql 会话......这本质上是一个批处理过程 - 将批处理的所有内容重定向到
my.out
Reference:
参考:
回答by Chris Lam
That should work, be aware of the db name.
这应该有效,请注意数据库名称。
mysql -v contact
If you db requires login:
如果您的数据库需要登录:
mysql -v -udbuser -p contact