Schlagwort-Archive: mysqldump

Copy MySQL tables across different servers with PHP

How to copy table1 from host1 to host2:

ini_set('memory_limit', '-1');
$execstring="mysqldump -h host1 -u user1 -ppassword1 databasename TblName | mysql -h host2 -u user2 -ppassword2 anotherDatabase";
exec($execstring, $output);


Aware: all the values after pipe (|) must not contain special characters (e.g. !) as they are interpreted by the bash. So escape them.

Backup source and target before testing.