sanjeev
sanjeev

Reputation: 11

migrate millions of mysql data to different database with different structure in php script

I have 4 millions of data, which some column I need to migrate in a new MySQL database. I need a PHP script which I can run without any memory failure and any data.

I found it will be better to use multibatch process. Can anyone suggest what is the better option and how to do it in PHP and linux ?

Upvotes: 1

Views: 160

Answers (1)

Peter
Peter

Reputation: 36

If the two databases are on the same server, then you could get good performance with a SELECT INTO, even across databases. Otherwise, you could export the data, and use load data in order to import it into the new structure 13.2.6 LOAD DATA INFILE Syntax.

If you're really determined to use php, then I'd suggest using background workers on a queue - this way each worker can process a small amount of records each (maybe 1000 - avoiding memory problems). This would take a while longer to run, and also to setup. We've used php-resque for something similar (running data from a DB into redis) with good success.

Upvotes: 1

Related Questions