【问题标题】:How to backup MySQL database from NSIS如何从 NSIS 备份 MySQL 数据库
【发布时间】:2012-12-05 02:51:13
【问题描述】:

我需要从 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

他们都没有工作。传递论点不是我的强项:(

【问题讨论】:

  • NSIS 语法对我来说看起来不错。有带空格的参数吗?在这种情况下,请为它们使用引号,例如 --user="$username"。要调试 cmd 行参数,请使用 FileWrite (nsis.sourceforge.net/Docs/Chapter4.html#4.9.5.8) 并将所有内容写入 .bat 文件。然后尝试执行.bat文件,看看结果。
  • @Slappy 不,任何地方都没有空格。从我提到的很多内容中,我不确定哪种 NSIS 语法适合您。无论如何,我得到了一个可行的解决方案。

标签: installation command-line-arguments nsis mysqldump database-backups


【解决方案1】:

这对我有用:

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 的原因,也没有引用。

【讨论】:

    猜你喜欢
    • 2011-10-31
    • 1970-01-01
    • 2019-02-08
    • 1970-01-01
    • 1970-01-01
    • 2011-03-02
    • 2011-11-10
    • 2011-04-25
    相关资源
    最近更新 更多