开发者

How to restore a MySQL dump file by Java?

开发者 https://www.devze.com 2023-02-16 10:14 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消