0

我需要从NSIS安装程序备份MySQL数据库。我在我尝试的脚本中丢失了一些微不足道的东西:如何从NSIS备份MySQL数据库

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 

他们都没有工作。传递的参数是不是我的最强套装:(

+0

NSIS语法对我来说看起来很不错。是否有任何带空格的参数?在这种情况下,为它们使用引号--user =“$ username”。使用FileWrite(http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.5.8)并将所有内容写入.bat文件。然后尝试执行.bat文件并查看结果。 – Slappy 2012-07-26 04:50:10

+0

@Slappy不,任何地方都没有空间。我不确定哪些NSIS语法对于我提到的很多。无论如何,我有一个工作解决方案。 – nawfal 2012-07-26 06:22:35

回答

0

这为我工作。

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

其重要不包括路径"D:\ctvi.sql"这样在执行命令,也不要引用路径变量,为什么我用$1,也没有引用。