MYSQL:从2个数据库中复制表的数据.两个数据库都位于不同的服务器(托管公司)中 [英] MYSQL : Copy data of tables from 2 databases. Both database are in different servers(Hosting companies)

查看:332
本文介绍了MYSQL:从2个数据库中复制表的数据.两个数据库都位于不同的服务器(托管公司)中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,可以从托管公司myhosting.com中的数据库表中复制数据.

I have an application where I copy data from a table of database which is in hosting company myhosting.com.

我需要将此数据复制到托管公司inmotionhosting.com中数据库的另一个表中

I need to copy this data to another table of a database which is in a hosting company inmotionhosting.com

它基本上是从两个位于不同托管公司的2个表中复制数据. 这两个数据库都是mysql,我在两个数据库中都拥有完全权限.

It is basically copying data from 2 tables which are in two different hosting company. Both the database are mysql and I have full rights in both the databases.

我知道我们可以下载整个数据库并在另一个托管公司中上载数据库,但这不能解决我的目的.

I know that we can download entire database and upload the database in another hosting company but it does not solve my purpose.

推荐答案

在PHP中,这应该非常容易.只需建立多个连接($ link1,$ link2等)-每个服务器一个.从$ link1中的表中选择数据,然后在$ link2中将其插入(或更新).

This should be very easy in PHP. Just make multiple connections ($link1, $link2, etc.) - one to each server. SELECT data from a table in $link1 and INSERT (or UPDATE) it in $link2.

唯一的问题是,托管公司通常默认情况下只会为本地服务器打开MySQL端口(通常为3306).如果真是这样,那么如果您的程序在服务器A上运行,则它可以毫无问题地连接到服务器A上的MySQL,但不能连接到服务器B上的MySQL.应该在服务器控制面板中提供一种简单的打开方法设置端口3306进行远程访问-如果没有,则必须要求托管公司(其中一个)为您执行此操作.

The only catch is that often a hosting company will only, by default, open MySQL port (normally 3306) for the local server. If that is the case, then if your program is running on server A then it will be able to connect to MySQL on server A without a problem but not MySQL on server B. There should be an easy way in the server control panel to open up port 3306 for remote access - if not then you will have to ask the hosting company (one of them) to do that for you.

这篇关于MYSQL:从2个数据库中复制表的数据.两个数据库都位于不同的服务器(托管公司)中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆