MySQL跨服务器选择查询
是否可以使用 MySQL 客户端编写跨服务器选择查询.基本上设置如下.
Is it possible to write a cross server select query using MySQL Client. Basically the setup is like follows.
服务器 IP 数据库
--------- --------
1.2.3.4 测试
a.b.c.d 测试
Server IP Database
--------- --------
1.2.3.4 Test
a.b.c.d Test
我想编写一个查询,从 1.2.3.4 上测试数据库的表中选择行,并将结果插入到 a.b.c.d 上的测试数据库中
我的服务器相距数英里,因此我将打开一个 SSH 隧道来连接两者.
I want to write a query that will select rows from a table in the Test Database on 1.2.3.4 and insert the result in a table into the Test Database on a.b.c.d
My servers are located miles apart so I will be opening a SSH tunnel to connect the two.
有什么指点吗?
推荐答案
mysqldump
可能是已经提到的解决方案,或者您可以尝试使用 SELECT ... INTO OUTFILE
> 然后是 LOAD DATA INFILE ...
命令.
mysqldump
could be a solution as mentioned already or you could try using the SELECT ... INTO OUTFILE
and then LOAD DATA INFILE ...
commands.
MySQL 确实有可能对您有用的联合存储引擎.这里有更多关于它的文档 http://dev.mysql.com/doc/refman/5.0/en/federated-storage-engine.html 我必须承认我没有取得巨大的成功,但它可能对你有用.
MySQL does have the federated storage engine which might be useful to you. Here's some more documentation on it http://dev.mysql.com/doc/refman/5.0/en/federated-storage-engine.html I have to confess that I've not had huge success with it but it might work for you.
第三个解决方案是在您的应用程序中完成工作.将SELECT
查询的结果逐行读入,并将INSERT
的结果逐行读入到另一个服务器.不过,您可能会在数据类型和 null 处理方面遇到一些问题.
The third solution would be to do the work in your application. Read in the results of the SELECT
query line by line and INSERT
to the other server line by line. You might run into some issues with data types and null handling that way though.
相关文章