Wolfy
Wolfy

Reputation: 11

Cloning database tables across to another server

New poster, longtime browser. I've looked around on here but cant seem to find the exact answer to my query.

I have a MySQL database running on a LAMP stack with two tables, one table has a list of products, the other table has a list of linked offers to these products. The Offers are refreshed daily using an import script and the products are persistent but new products might be added occasionally by the same import script.

Products table is around 1,000 records. The offers table can be upwards of 1.5 million with around 15-20 columns of data.

I also have another MySQL database on another LAMP stack, the tables are the same.

The import script on server #1 runs at 7am as that is when new offers are available.

What I want to do is clone the Offers table across to server#2. The current method my developer has used takes 3-4 hours but this isn't going to work as I need the deals updated by 9am.

I've seen multiple posts on backing up, exporting and importing the data. But not sure if this would work since they are on different servers.

Anyone have some tips, pointers you can give please?

Edit: TO add - the original import takes about an hour max. It's usually complete by 8am.

Upvotes: 1

Views: 178

Answers (1)

abhijeet.supekar
abhijeet.supekar

Reputation: 177

Option 1:

Dump the table with using mysqldump and import the dumped file in the other Server :

mysqldump - root -p db1 tabletoexport > table.sql

For importing it on the other server:

mysql -u root -p db2 < table.sql

Option 2:

For future purpose instead of this you can setup a Master-Slave Replication.

https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql

Upvotes: 2

Related Questions