我想在我的前端设置一个按钮,点击该按钮后,我想备份我的mysql数据库并下载sql文件。真的有办法完成这个任务。谢谢。
Process p = null;
try {
Runtime runtime = Runtime.getRuntime();
p = runtime.exec("mysqldump -u dinmarkh_root -pushanlac absdfer_bldb > /home/abcd/a.com/back.bcdsql");
InputStream inputStream = p.getInputStream();
ServletOutputStream strm = resp.getOutputStream();
byte[] buffer = new byte[4096];
int bytesRead = -1;
while ((bytesRead = inputStream.read(buffer)) != -1) {
strm.write(buffer, 0, bytesRead);
}
inputStream.close();
strm.close();
int processComplete = p.waitFor();
if (processComplete == 0) {
System.out.println("Backup created successfully!");
} else {
}
} catch (Exception e) {
e.printStackTrace();
}
暂无答案!
目前还没有任何答案,快来回答吧!