简体   繁体   中英

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.

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.

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

I suggest using "SELECT ... INTO OUTFILE" to extract your data on the first server.
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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM