title: How to Backup mysql db from Remote to local without mysql local installation?
body: <p>Good Day, I am trying to take mysql backup from remote server to my local machine. I am able to do so, when i have mysql client installed on local machine. But when the client doesnt have local mysql client installation, it is not working ...</p>
  
  <p>I have been connecting to mysql server using the jdbc connection and my code snippet is as follows:</p>
  
  <pre><code>try{     
  String cs = "jdbc:mysql://" + dbh + ":" + dbport + "/" + database + "?user=" + USER + "&amp;password=" + PASS+"";
  Class.forName("com.mysql.jdbc.Driver").newInstance();
  connection = java.sql.DriverManager.getConnection(cs);
  String executeCmd = "";
       if(connection!=null){
          executeCmd = "mysqldump -u "+USER+" -p"+PASS+" "+database+" -r "+path;   
          Process runtimeProcess =Runtime.getRuntime().exec(executeCmd);
          int processComplete = runtimeProcess.waitFor();
          if(processComplete == 0){
              System.out.println("Backup taken successfully");
          } else {
              System.out.println("Could not take mysql backup");
          }
      } else{
          System.out.println("connection not sucess");
      }
  }catch (Exception e) {
              e.printStackTrace();
  }
  </code></pre>
  
  <p>I think this might be some problem with mysqldump PATH, so i copied this file to client machine, and specified absolute path to mysqldump in <code>executeCmd</code>. This time the backupfile is created in specified path, but its empty &amp; <code>processComplete</code> returns a value <code>2</code>. 
  My Questions are,</p>
  
  <ol>
  <li>Do i need any other mysql files to run the mysqldump command? If so how to do that other than copy these commands to local machine?</li>
  <li>What does waitFor() with return value 2 mean?</li>
  </ol>
  
  <p>Thanks &amp; Regards</p>
  
  <p>iMmo</p>