开发者

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:/开发者_Python百科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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜