1
Runtime.getRuntime().exec("C:\\mysql\\bin\\mysqldump -u root -pmypassword  Databasename -r C:/backup.sql");

I am using this code to create back up from my sql. but It creates the empty file in the path.Because it is waiting in the command prompt to get the password. How can i give password to it Using command prompt directly when i press enter after typing, it asks password.After giving password,It creates the backup.Give me any solution for this Thanks in advance

1
  • @Arivu2020 any progress? did you solve your problem? If yes - mark an answer as accepted Commented Mar 17, 2010 at 12:51

2 Answers 2

2

try the longer version

C:\mysql\bin\mysqldump -u root --password=mypassword Databasename -r C:/backup.sql

are you sure this password is correct?

Sign up to request clarification or add additional context in comments.

Comments

1

Leave a space between -p and mypassword, like this:

Runtime.getRuntime().exec("C:\\mysql\\bin\\mysqldump -u root -p mypassword Databasename -r C:/backup.sql");

Parameters to mysql commands often take two forms: The short form is -o value (with a space between), the longer form is --option=value (no space). You can't mix 'n' match the syntax.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.