[英]Backup mysql from remote database with mysqldump process error
I want to make a backup of my remote mysql database. 我想备份我的远程mysql数据库。 I have viewed many examples, but I can not find the answer what I am doing wrong.
我查看了许多示例,但找不到正确的答案。 I have mysql server on my computer with other name than my remote database, just want to create sql file in my computer to have a copy.
我的计算机上有mysql服务器,其名称与远程数据库不同,只想在计算机上创建sql文件以获取副本。 My button action performed code is:
我的按钮操作执行的代码是:
try {
String cs = "jdbc:mysql://db4free.net:3306/DBNAME?user=DBUSER&password=DBPASSWORD";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = java.sql.DriverManager.getConnection(cs);
String executeCmd = "";
if (connection != null) {
executeCmd = "mysqldump -hwww.db4free.net -u DBUSER -pDBPASSWORD DBNAME > backup.sql";
Process runtimeProcess = Runtime.getRuntime().exec(new String[] { "cmd.exe", "/c", executeCmd });
int processComplete = runtimeProcess.waitFor();
if (processComplete == 0) {
JOptionPane.showMessageDialog(rootPane, "OK");
} else {
JOptionPane.showMessageDialog(rootPane, "Didn't make a copy.");
}
} else {
JOptionPane.showMessageDialog(rootPane, "Failed");
}
} catch (Exception e) {
e.printStackTrace();
}
The system cannot find the file specified 该系统找不到指定的文件
Try adding path to the file 尝试将路径添加到文件
executeCmd = "/usr/bin/mysqldump -hwww.db4free.net -u DBUSER -pDBPASSWORD DBNAME > backup.sql";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.