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.