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跨服务器选择查询
基础教程推荐
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01