Mysql – How to copy one table data to another on different server

MySQL

I have country-wise MySQL servers and one master server.

The master server has all country data.

In that I want to copy data of a particular country from the master MySQL server.

Example: if any data inserted on the master MySQL server is related to India, it will also be inserted into the Mysql server in India.

How can this be achieved?

Table structures in both a country-level server and the master server are the same:

--
-- Table structure for table `vxp_service_types`
--
CREATE TABLE IF NOT EXISTS `vxp_service_types` (
  `st_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `st_name` varchar(25) NOT NULL,
  PRIMARY KEY (`st_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ;

Best Answer

You could restrict on table level. This can be done by ignoring some tables, or by only specifying the databases/tables that you want.

http://dev.mysql.com/doc/refman/5.0/en/replication-options-slave.html#option_mysqld_replicate-do-table

Example: --replicate-wild-do-table=foo%.bar% replicates only updates that use a table where the database name starts with foo and the table name starts with bar.

Example: --replicate-wild-ignore-table=foo%.bar% does not replicate updates that use a table where the database name starts with foo and the table name starts with bar.