简体   繁体   English

将具有1.3 MIL记录的表从一台MysQL服务器移动到另一台(在不同的物理服务器上)

[英]Move Table with 1.3 MIL records from one MysQL Server to Another (on different physical servers)

We have a query that we run, it is an Insert from Select statement, and it literally finishes in seconds - and is able to insert 1.3 million records with ease. 我们有一个查询在运行,它是一个从Select语句插入的语句,字面意义是在几秒钟内完成-能够轻松插入130万条记录。

We have new requirements. 我们有新的要求。 The table that is being created and inserted into must now exist on a DIFFERENT mysql server on the same subnet. 现在,要创建并插入其中的表必须存在于同一子网的不同mysql服务器上。

How can this be done? 如何才能做到这一点? What is the most efficient manner to do this? 最有效的方法是什么? Should we backup the table at a file level, and copy it to the new server? 我们应该在文件级别备份表,然后将其复制到新服务器吗?

Or should we run a query against both databases, and if so - how long will it take? 还是我们应该对两个数据库都运行查询,如果是的话,这需要多长时间?

We need to do this process manually - 我们需要手动执行此过程-

Here is an example of the current code that we use to do this: 这是我们用于执行此操作的当前代码的示例:

$populateNewTable = "insert into tbl_free_minutes_".strtolower(date("M")).date("Y")." (cust_id,telephone_number,state,created_datetime,plan_id,requested_planid) SELECT id,telephone_number,state,created_datetime,plan_id,requested_planid FROM tbl_customer WHERE created_datetime <= '".$date." 23:59:59' AND account_status IN ( 'Active', 'ActiveLL','Suspend') AND  plan_id IN ('14','13','15','16','17','19','20','21','22','23','24','60','26', '27','28','29','30','31','32','33','34','38','39','40','44','45','46','47','48', '49','50','51','52','53','54','55','56','57','58','59','35','36','66','63','64', '65','67','68','69',76,77,78,79,82,83,84,85,86,87,88,89,93,94,95,96) and unlimited_plan != 'Y' ";

Sas SAS

I suggest using "SELECT ... INTO OUTFILE" to extract your data on the first server. 我建议使用“ SELECT ... INTO OUTFILE”在第一台服务器上提取数据。
Then transfer the file created by the query to the second server. 然后将查询创建的文件传输到第二台服务器。
And last, use "LOAD DATA INFILE" on the second server to load your data in your table. 最后,在第二台服务器上使用“ LOAD DATA INFILE”将数据加载到表中。

Some links: 一些链接:
http://dev.mysql.com/doc/refman/5.5/en/select-into.html http://dev.mysql.com/doc/refman/5.5/en/select-into.html
http://dev.mysql.com/doc/refman/5.5/en/load-data.html http://dev.mysql.com/doc/refman/5.5/en/load-data.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将数据从一个 MySQL 表移动到另一个表 - Move data from one MySQL table to another 如何在PHP和MySQL中将几条记录从一台服务器上的表复制到另一台服务器上具有相同结构的表? - How to copy few records from a table on one server to the table with same structure on another server in PHP and MySQL? 将一个数据库中的数据插入另一台服务器上的另一个数据库中-未链接的服务器 - Insert data from one DB into another on a different server - servers not linked 如何将一行从一个表移动到mysql中的另一个表? - How to move one row from one table, to another table in mysql? PHP Mysql:如何将特定的记录从一个数据库插入另一个数据库的另一台服务器? - PHP Mysql : How to insert specific records from one db to another db different server? 将数据库表从一台服务器发送到另一台服务器中的另一数据库表PHP MySQL - Send database table from one server to another database table in different server PHP MySQL MySQL将随机行从一个表移动到另一个表 - MySQL move random row from one table to another 使用转义值将mysql数据从一个表移动到另一个表 - Move mysql data from one table to another with escaped values 从一张桌子移动到另一张桌子 - Move from one table to another 搜索具有超过300万条记录的mysql数据库 - Searching mysql database that has over 3 mil records
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM