1

这是我尝试导出数据库的代码。

    //MysqlPath = "C:\Program Files\MySQL\MySQL Server 5.1\bin\"
    String executeCmd = "\"" +Mysqlpath+ " mysqldump -u " + dbUser
                + " -p" + dbPass + " " + dbName + " -r " + FilePath + "\\"
                + FileName;

    System.out.println(executeCmd);
    Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);

我收到以下错误:

***Cannot run program """C:\Program": CreateProcess error=87, The parameter is incorrect***

我该如何解决这个问题?

4

2 回答 2

2

我希望这可以帮助你,从java代码运行转储命令

  Runtime.getRuntime().exec("mysqldump -u username -p password  databasename > /../.. datadump.sql");

如果错了请纠正我

于 2012-09-18T06:37:23.890 回答
1

试试这个 :

File fMysqlPath = new File("C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\");
String executeCmd = "mysqldump -u " + dbUser
            + " -p" + dbPass + " " + dbName + " -r " + FilePath + "\\"
            + FileName;

System.out.println(executeCmd);
Process runtimeProcess = Runtime.getRuntime().exec(executeCmd, null, fMysqlPath);

Java 1.4.2

于 2012-09-18T07:44:31.467 回答