MySQL mysqldump 命令的 Windows 批处理文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14139743/
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
windows batch file for mysqldump command
提问by Learnner
this is first time I am upto making a windows batch file.I wish not to do experiments first as its related to live server. I use to back up mySql database by following open cmd write
这是我第一次制作 Windows 批处理文件。我不想先做实验,因为它与实时服务器有关。我用open cmd write 来备份mySql 数据库
mysqldump -u user -p DBname >C:\DBname.sql
then cmd ask password
然后cmd询问密码
password = password
I want to make a windows batch file ,upon click I wish to perform the above functionality. Can any one please give some instructions related script of .bat file
我想制作一个 Windows 批处理文件,点击后我希望执行上述功能。任何人都可以提供一些.bat文件相关脚本的说明
So far I wrote this
到目前为止我写了这个
ECHO OFF
mysqldump -u user -p DBname >C:\DBname.sql
GO
SET password = password
Go
but still it prompts me for password . I wish password get enter automatically
但它仍然提示我输入密码。我希望密码自动输入
回答by Sean409
The above was still prompting me for a password I used whats below to get it to work correctly.
以上仍然提示我输入密码,我使用下面的内容使其正常工作。
"C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin\mysqldump.exe" -uroot -pDBPass DBName > C:\DBname.sql
回答by Jay Lee
The one-liner:
单线:
mysqldump -u user -p DBname --password YOURPASSWORD > C:\DBname.sql
mysqldump -u user -p DBname --password YOURPASSWORD > C:\DBname.sql
should do it.
应该这样做。
回答by u8861268
You can use this:
你可以使用这个:
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe" -u root -proot test > D:\DBname.sql
Please note this: -proot
, the p
and root
must be together
请注意:-proot
,p
和root
必须在一起