public class Mysql
{
Mysql()
{
}
public void Put() throws IOException{
Date date=new Date();
SimpleDateFormat ff=new SimpleDateFormat("yyyyMMddhhmmss");
String da=ff.format(date);
String name=da+"back.sql";
String command = "mysqldump -h 192.168.26.200 -u root -p123 --opt ec > d:/"+name; //test -p root -p
Runtime.getRuntime().exec("cmd /c "+command);
System.out.println(" ");
}
public void In() throws IOException{
Date date=new Date();
SimpleDateFormat ff=new SimpleDateFormat("yyyyMMddhhmmss");
String da=ff.format(date);
String command = "mysql -h 127.0.0.1 -u root -p123 test < d:/test.txt";
Runtime.getRuntime().exec("cmd /c "+command);
System.out.println(" "+da);
}
public static void main(String [] ages)
{
Mysql my=new Mysql();
try{
my.Put();
}
catch(Exception y)
{
y.toString();
}
}
Mysql path mysql bin , Cannot run program "mysqldump": CreateProcess error=2, The system cannot find the file specified