I am using mysqldump like this:
Runtime.getRuntime().exec("mysqldump -u USERNAME -pPASSWORD DBNAME > /path/to/location/backup.sql");
in order to dump it into my local files, my java program is deployed using kubernetes.
Here is my code:
@RequestMapping(value = "/testDumping", method = {RequestMethod.POST, RequestMethod.GET})
public Object test(@RequestBody Map<String,Object> params) throws IOException {
String runStatement = (String)params.get("runStatement");
Runtime runtime = Runtime.getRuntime();
Process exec = runtime.exec(runStatement);
return exec;
}
And I finally got this exception "java.io.IOException: Cannot run program "mysqldump": error=2, No such file or directory". What is the problem here?
Copyright License:
Author:「Xiaoyu Wu」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/68196117/backup-mysql-database-from-java-using-mysqldump-failed