Backup mysql database from Java using mysqldump failed

2021-06-30T21:51:25

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

About “Backup mysql database from Java using mysqldump failed” questions

I want to backup my database using mysql dump. This is the code I run in Command prompt when the location is mysql bin. mysqldump -u root -pabc Db -r C:\Documents and Settings\All Users\Desktop\ttt...
I am using mysqldump like this: Runtime.getRuntime().exec(&quot;mysqldump -u USERNAME -pPASSWORD DBNAME &gt; /path/to/location/backup.sql&quot;); in order to dump it into my local files, my java p...
I was able to create a backup of my current mysql database as .SQL file using the mysqldump.exe with the help of the following java code. Process runProcess = Runtime.getRuntime().exec("C:\\SCM ...
I'm trying to take a backup of a mysql database using the following code. public boolean backupDB() { String executeCmd = "mysqldump -u root -p 1234 --add-drop-database -B test -r D:\\bac...
I have a mysql database with the name "BooksDB" and i want to take a backup file i'm using mysqldump i write the line below: c:\Program Files\MySQL\MySQL Server 5.6\bin> mysqldump -uroot -pbooks
I want to backup a mysql database which is a remote server monitoring over ssh. So, I wrote a code using mysqldump and java to achieve this task. My remote server details are mentioned below. Conn...
I am new to using mysql and i am trying to backup a mysql database using mysqldump. So this is what i have done so far:- I ssh'ed into my VM and run mysql to get into the mysql CLI Then i ran the
I try to create a backup for my database. My database is MySQL. I am using PHP. I use a cron job to execute this code every hour. This is my code: $dbhost = 'localhost'; $dbuser = 'root'; $dbpass...
I want to make a backup of my remote mysql database. 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 re...
How can I make a complete backup of mysql database using mysqldump? When I am making a backup, my tables from specified database are only getting backed up. The procedures and functions are not. H...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.