MySQL Cross Server Select Query(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跨服务器选择查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL跨服务器选择查询


基础教程推荐
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01