java的mysql数据库还原问题
在执行下还原数据库代码时,可以建立数据库,但是不能还原数据。
public static void load(String fileName) throws Exception {
String username = "root";
String password = "root3306";
String mysqlpath = "D:\\DeveloperTools\\MySQL\\MySQL Server 5.6\\bin\";
String databaseName = "nasystem";
String address = "localhost";
String sqlpath = "D:\";
// 建立数据库
String createDatabase = mysqlpath + "mysqladmin -u" + username + " -p"
+ password + " create " + databaseName;
// 还原数据库数据
String loadData = mysqlpath + "mysql -h " + address + " -u"
+ username + " -p" + password + " " + databaseName + " < "
+ sqlpath + fileName;
System.out.println("建立数据库:" + createDatabase);
System.out.println("还原数据:" + loadData);
Runtime r = Runtime.getRuntime();
r.exec(createDatabase);
r.exec(loadData);
}