MySQL跨服务器选择查询

MySQL Cross Server Select Query(MySQL跨服务器选择查询)
本文介绍了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.

这篇关于MySQL跨服务器选择查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Can#39;t Create Entity Data Model - using MySql and EF6(无法创建实体数据模型 - 使用 MySql 和 EF6)
MySQL select with CONCAT condition(MySQL选择与CONCAT条件)
Capitalize first letter of each word, in existing table(将现有表格中每个单词的首字母大写)
How to retrieve SQL result column value using column name in Python?(如何在 Python 中使用列名检索 SQL 结果列值?)
Update row with data from another row in the same table(使用同一表中另一行的数据更新行)
Exporting results of a Mysql query to excel?(将 Mysql 查询的结果导出到 excel?)