从Windows 7上的可执行文件MySQLDump

编程入门 行业动态 更新时间:2024-10-11 05:25:39
本文介绍了从Windows 7上的可执行文件MySQLDump的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图通过调用一个wsh jscript文件来转储一个mysql数据库,但它不起作用。

我有这个代码,用git shell调用,它完美地工作:

#如果失败,退出状态不是0 set -e #选择转储目录 cd$(git rev-parse --show-toplevel) #先删除原来的模式 rm -f WebShop\DataBase\backup.sql #生成一个新模式 execC:\程序文件\ MySQL\MySQL Server 5.5\bin\mysqldump。 ($),\\\($ g'>WebShop\DataBase\backup.sql

我在WSH中尝试了几乎相同的代码,但它仅返回转储文件的标头, t创建文件,我没有线索说明什么是错误的,或者如何调试代码......:S pre $ code > var shellObj = WScript.CreateObject('WScri pt.Shell'); var exec = shellObj.Exec('C:\\ Program Files \\MySQL\\MySQL Server 5.5\\\\\\\ \mysqldump.exe'+ --skip-comments -u root --password = root webshopdb | sed's $),($),\\($ g'> + 'D:\\creation\\\ software software developer\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ DataBase \\backup.sql'); WScript.Echo(exec.StdOut.ReadAll());

我也尝试过使用bat文件和cmd文件,但无法处理这些空间。

任何人都可以帮忙(对我来说,从git代码做一个可执行文件就足够了,或者让wsh工作......完美的解决方案是,如果我可以调用从netbeans转储,但在生活中没有什么是如此理想......:D)

解决方案

我用文件关联做了它。

我创建了一个git.bat文件:

如果不存在%1退出 set bash = C:\程序文件(x86)\Git\bin\bash.exe %bash%--login -i -cexec% 1

并将其关联到.hook文件。

之后,我创建了一个测试dump.hook文件:

#!/ bin / sh cdD:/ creation / software developer / projects / webshop -refactoring-project / document root / WebShop; cd$(git rev-parse --show-toplevel) rm -fWebShop / DataBase / backup.sql execC:/ Program Files / MySQL / MySQL Server 5.5 / bin / mysqldump.exe--skip-comments -u root --password = root webshopdb | sed's $),($),\\\($ g'>WebShop / DataBase / backup。 sql exit

它完美地工作。

3天后我收到了!Woohoo!:D

注意:* Windows命令提示符通常在路径名中包含空格和特殊字符,因此使用git的模拟linux要比修复它容易得多,也可以将.hook文件提交到预先提交的git钩子中,这样它就可以在每次提交时自动转储数据库模式。 ..(也许git添加不工作的这些文件,我还没有找到一个自动转储和提交解决方案呢: git pre-commit + mysqldump:找不到路径,不能找到路径现有命令)*

I tried to dump a mysql database with calling a wsh jscript file, but it doesn't work.

I have this code, called with git shell, and it works perfectly:

# If something fails, exit with status other than 0 set -e # select dump directory cd "$(git rev-parse --show-toplevel)" # first, remove our original schema rm -f "WebShop\DataBase\backup.sql" # generate a new schema exec "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe" --skip-comments -u root --password=root webshopdb |sed 's$),($),\n($g' > "WebShop\DataBase\backup.sql"

I tried almost the same code in WSH, but it returns only with the header of the dump file, and doesn't creates the file. I do not have a clue what is working wrong, or how to debug the code... :S

var shellObj = WScript.CreateObject('WScript.Shell'); var exec = shellObj.Exec( '"C:\\Program Files\\MySQL\\MySQL Server 5.5\\bin\\mysqldump.exe"'+ " --skip-comments -u root --password=root webshopdb |sed 's$),($),\\n($g' > " + '"D:\\creation\\software developer\\projects\\webshop-refactoring-project\\document root\\WebShop\\DataBase\\backup.sql"' ); WScript.Echo(exec.StdOut.ReadAll());

I tried with bat files and cmd files too, but they cannot handle the space in the pathes.

Can anybody help?

(For me it would be enough to make somehow an executable from the git code, or make the wsh work... The perfect solution would be if I could call the dump from netbeans, but in life nothing is so ideal... :D )

解决方案

I made it with file association.

I created a git.bat file:

if not exist %1 exit set bash=C:\Program Files (x86)\Git\bin\bash.exe "%bash%" --login -i -c "exec "%1""

And associated it to .hook files.

After that I created a test dump.hook file:

#!/bin/sh cd "D:/creation/software developer/projects/webshop-refactoring-project/document root/WebShop"; cd "$(git rev-parse --show-toplevel)" rm -f "WebShop/DataBase/backup.sql" exec "C:/Program Files/MySQL/MySQL Server 5.5/bin/mysqldump.exe" --skip-comments -u root --password=root webshopdb |sed 's$),($),\n($g' > "WebShop/DataBase/backup.sql" exit

And it works perfectly.

After 3 days I got it! Woohoo! :D

note: *Windows command prompt usually has problems with whitespace and special characters in the path name, so it is much easier to use the emulated linux of git, than try to fix it. It is possible to source the .hook file into a pre-commit git hook too, so it can automatically dump the database schema by every commit... (maybe the git add not working by those files, I haven't found an auto dump and commit solution yet: git pre-commit + mysqldump: cannot find path, not existing command) *

更多推荐

从Windows 7上的可执行文件MySQLDump

本文发布于:2023-10-29 00:23:19,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可执行文件   Windows   MySQLDump

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!