I am trying to get the backup of SQL file using the below status code, returning status code:0, when assumed as cmd it is executed successfully but otherwise there is some error.
So the below code is running successfully but the output file is not generating don't know why.
Code:
String filePath="/backup/";
String executeCmd = "mysqldump -u " + user + " " + dbname + " -r " + filePath+"backup.sql";
//String executeCmd = "mysqldump -u " + user + " -p" + password + " " + dbname + " -r " + filePath+" backup.sql";
Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);
status = runtimeProcess.waitFor();
if (status == 0) {
System.out.println("Backup taken successfully");
} else {
System.out.println("Could not take mysql backup");
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…