How to restore a MySQL dump file by Java?
I backup my MySQL databse to a specific folder, say, d:\backup\
by a webpage. The ba开发者_C百科ckup goes without issues, but I am not able to restore it using the following command.
Runtime.getRuntime().exec("mysql -u root -p root sgapp < D:/backup/bkup.sql");
What is the cause and how can I solve this?
Runtime.getRuntime().exec("mysql -u USERNAME -pPASSWORD DBNAME < D:/backup/bkup.sql");
Mind the lack of gap between -p and password string.
That works for me:
Runtime.getRuntime().exec("cmd /c start mysqldump -u root -ptestpsw workone -rscript_name.sql");
use -rfilename.sql
instead of redirect < .
Maybe it works for you too.
精彩评论