简体   繁体   English

MySQl转储不适用于防火墙

[英]MySQl dump not working with firewall

I'm using -msqldump to backup the database in remote machine. 我正在使用-msqldump备份远程计算机中的数据库。 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. 我已将以下代码发布到Web服务器中,并尝试从另一个域进行备份。

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. 如果您在谈论MySQL Port 3306对外开放的Web服务器,通常会使用服务器端脚本语言(例如PHP)来连接数据库,生成转储并将其传递给请求者。

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. 为此,有各种各样的脚本,一些脚本调用远程命令行mysqldump,一些脚本使用PHP内置的mySQL函数连接到数据库。

If it's a one time thing, you want to look at phpMyAdmin that you would install remotely. 如果这是一次性的事情,那么您需要查看将远程安装的phpMyAdmin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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