Cannot Run Program Mysqldump Createprocess Error=2
Contents |
here for a quick overview of the site Help Center Detailed answers to how to take backup of mysql database using java any questions you might have Meta Discuss the workings and how to take backup of mysql database using java swing policies of this site About Us Learn more about Stack Overflow the company Business Learn more
Mysqldump Command
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error when backing up MYSQL database up vote 1 down vote favorite 1 I'm sorry for the stupid question, but when i run this code i always get a error. This code is meant to get a backup from my mysql database and display it. For your information, remote mysql is enabled. Here is the code: private void backupDatabaseButtonActionPerformed(ActionEvent e) { try { Runtime.getRuntime().exec("mysqldump -u user -p pass db > C:\\backup.sql"); } catch (IOException e1) { e1.printStackTrace(); } } I replaced the user, pass and db with the correct login details, but i always get an error. Here is the error: java.io.IOException: Cannot run program "mysqldump": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at databaseTools.backupDatabaseButtonActionPerformed(databaseTools.java:23) at databaseTools.access$0(databaseTools.java:20) at databaseTools$1.actionPerformed(databaseTools.java:51) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEve
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million http://stackoverflow.com/questions/15850548/error-when-backing-up-mysql-database programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Take MySQL backup up vote 2 down vote favorite 2 I need to avoid the error and store database backup in separate file path using mysqldump public class NewClass { public static void main(String args[]) throws IOException, SQLException { String http://stackoverflow.com/questions/17744946/take-mysql-backup dbName = "test"; String dbUser = "root"; String dbPass = "root"; try { String executeCmd = ""; executeCmd = "mysqldump -u " + dbUser + " -p" + dbPass + " " + dbName + " -r backup.sql"; 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"); } } catch (InterruptedException ex) { Logger.getLogger(NewClass.class.getName()).log(Level.SEVERE, null, ex); } } } ERROR:run: Exception in thread "main" java.io.IOException: Cannot run program "mysqldump": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042) at java.lang.Runtime.exec(Runtime.java:615) at java.lang.Runtime.exec(Runtime.java:448) at java.lang.Runtime.exec(Runtime.java:345) at mypkg.NewClass.main(NewClass.java:27) Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.(ProcessImpl.java:288) at java.lang.ProcessImpl.start(ProcessImpl.java:133) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023) ... 4 more Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) java mysql mysqldump share|improve this question edited Jul 19 '13 at 11:29 Alexandre P. Levasseur 5,67822547 asked Jul 19 '13 at 11:25 Kannan 24128 Is mysqld
CommunityOracle User Group CommunityTopliners CommunityOTN Speaker BureauJava CommunityError: You don't have JavaScript enabled. This tool uses JavaScript and much of it will not work https://community.oracle.com/thread/1326368 correctly without it enabled. Please turn JavaScript back on and reload this page. Please enter a title. You can not post a blank message. Please type your message and try again. More discussions in Java - JDBC Archive All PlacesOracle CommunityArchived ForumsJava - JDBC Archive This how to discussion is archived 12 Replies Latest reply on Apr 17, 2008 3:11 PM by dcminter backup not taking 843859 Jan 16, 2015 5:03 PM hi to all,I've a backup code but that will not be taking the backup..String ip="localhost"; String port="3306"; String database="rich"; String user="username"; String how to take pass="password"; String path; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(".")); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.showSaveDialog(null); path = chooser.getSelectedFile().getAbsolutePath(); System.out.println(path); String dumpCommand = "mysqldump " + database + " -h " + ip + " -u " + user +" -p" + pass; Runtime rt = Runtime.getRuntime(); File test=new File(path); PrintStream ps; try{ Process child = rt.exec(dumpCommand); ps=new PrintStream(test); InputStream in = child.getInputStream(); int ch; while ((ch = in.read()) != -1) { ps.write(ch); System.out.write(ch); //to view it by console } JOptionPane.showMessageDialog (null,"BackUP Successfully Completed"); InputStream err = child.getErrorStream(); while ((ch = err.read()) != -1) { System.out.write(ch); } }catch(Exception exc) { exc.printStackTrace(); } This code is throwing this error path=/home/VEL AREA/backupfile.sql java.io.IOException: Cannot run program "mysqldump": java.io.IOException: error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:459) at java.lang.Runtime.exec(Runtime.java:593) at java.lang.Runtime.exec(Runtime.java:431) at java.lang.Runtime.exec(Runtime.java:328) at richwoods.MasterScreen.actionPerformed(MasterScreen.java:682) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButto