简体   繁体   中英

MySQl dump not working with firewall

I'm using -msqldump to backup the database in remote machine. If firewall is enabled i cannot login to the other hosts.Is there any solution for this problem.

I have posted the below coding in a web server and trying to backup from another domain.

String dumpCommand = "D:/MySQL/MySQL Server 5.0/bin/mysqldump -h"+scheduleInfo.get("hostName")+" -u"+scheduleInfo.get("user")+" -p"+scheduleInfo.get("password")+" "+scheduleInfo.get("dbName");
        Runtime rt = Runtime.getRuntime();
       try 
       {
            Process proc = rt.exec(dumpCommand);                     
            InputStream in = proc.getInputStream();                       
            BufferedReader br=new BufferedReader(new InputStreamReader(in));
            String line=null;
            File directory=new File(context.getJobDetail().getDescription());
            if(!directory.exists())
            {
                directory.mkdir();
            }
            File f=new File(directory.getAbsolutePath()+"\\"+context.getTrigger().getJobName()+".sql");
            System.out.println(f.getAbsolutePath());
            FileWriter fw=new FileWriter(f,true);
            fw.append("CREATE DATABASE /*!32312 IF NOT EXISTS*/ `"+scheduleInfo.get("dbName")+"` /*!40100 DEFAULT CHARACTER SET latin1 */;\nUSE `"+scheduleInfo.get("dbName")+"`;\n");
            while((line=br.readLine())!=null)
            {
                System.out.println(line);
                fw.append(line+"\n");
            }
            fw.close();
        } 

If you are talking about web servers with the mySQL Port 3306 closed to the outside world, you would usually employ a server side scripting language such as PHP to connect to the database, produce the dump, and pass it through to the requester.

There are various scripts around for this, some calling the remote command line mysqldump, some connecting to the database using PHP's built in mySQL functions.

If it's a one time thing, you want to look at phpMyAdmin that you would install remotely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM