[英]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.