如何从NSIS备份MySQL数据库 [英] How to backup MySQL database from NSIS

查看:245
本文介绍了如何从NSIS备份MySQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从NSIS安装程序中备份MySQL数据库。我在尝试的脚本中缺少一些琐碎的东西:

I need to backup a MySQL database from an NSIS installer. I am missing something trivial in the scripts I tried:

nsExec::Exec '"$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --routines $dbName --execute="source D:\$dbName.sql"' $0

nsExec::Exec '"$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --routines $dbName --execute="D:\$dbName.sql"' $0

nsExec::Exec '"$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --execute="--user=$username --password=$password --routines $dbName D:\$dbName.sql"' $0

nsExec::Exec '"$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --routines $dbName "D:\$dbName.sql"' $0

nsExec::Exec '"$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password /c echo --routines $dbName > "D:\$dbName.sql"' $0

ExecWait '"$1" /C "$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --routines $dbName > "D:\$dbName.sql"' $0

ExecWait '/C "$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password --routines $dbName > "D:\$dbName.sql"' $0

StrCpy $BACKUPFILE "D:\ctvi.sql"
StrCpy $1 $BACKUPFILE
ExpandEnvStrings $2 %COMSPEC%
ExecWait '"$2" /C "$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password $dbName > $1' $0

ExecWait '/C "$mySqlDirectory\bin\mysqldump.exe" -u$username --password=$password -R $dbName >"D:\$dbName.sql"' $0

没有一个有效。传递参数不是我最适合的方法:(

None of them worked. Passing argument is not my strongest suit :(

推荐答案

这对我有用:

StrCpy $1 "D:\ctvi.sql"
ExpandEnvStrings $2 %COMSPEC%
ExecDos::exec /NOUNLOAD '"$2" /C "$mySqlDirectory\bin\mysqldump.exe" --user=$username --password=$password $dbName > $1' $0

重要的是,不要在execute命令中包含路径 D:\ctvi.sql ,也不要引用引号路径变量。这就是为什么我使用 $ 1 的原因,也没有引用。

Its important not to include the path "D:\ctvi.sql" as such in the execute command, also not to quote the path variable. That is why I have used $1, that too without quoting.

这篇关于如何从NSIS备份MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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