-1
以下是我嘗試使用的代碼將.sql轉儲恢復到本地XAMPP服務器上的MySQL數據庫。我只是看不到我做錯了什麼。誰能幫忙?恢復MySQL .sql dump在嘗試本地XAMPP時無法正常工作MySQL服務器
try {
String dbName = "Database";
String dbUser = "root";
String dbPass = "";
String[] executeCmd = new String[]{"/Applications/XAMPP/bin/mysql", " --user=" + dbUser, " --password=" + dbPass, " "+dbName, " -e", " source "+s};
Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);
int processComplete = runtimeProcess.waitFor();
System.out.println(processComplete);
if (processComplete == 0) {
JOptionPane.showMessageDialog(null, "Successfully restored);
} else {
JOptionPane.showMessageDialog(null, "Error restoring");
}
} catch (IOException | InterruptedException | HeadlessException ex) {
JOptionPane.showMessageDialog(null, "Error" + ex.getMessage());
}
我想以編程的方式來完成它,就像在程序中具有保存和加載功能一樣。 – Bryce