Reputation: 2573
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
Upvotes: 1
Views: 133
Reputation: 425448
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.
Upvotes: 1
Reputation: 12087
try the longer version
C:\mysql\bin\mysqldump -u root --password=mypassword Databasename -r C:/backup.sql
are you sure this password is correct?
Upvotes: 2