Mysql – filter records within MySQL replication

MySQLreplication

I'm new to replication process.

In one of Rails project it's necessary to share records of one table between two applications.

Let's say share records between first application DB A and second application DB B.
I decided to move that logic on DB level.

  • Is is possible to configure MySQL replication in order to copy only particular records (e.g. records where need_to_replicate_to_B_flag = true)?
  • Or I should find another way to implement this?

Best Answer

You can filter on databases and/or tables only. See the manual on binlog/replicate-do/ignore-db/table

The filtering can be before leaving the Master (binlog-...) or as it comes into the Slave (replicate-...).

The main intent of Replication is for the Slave to be an identical copy of the Master. Your request is deviating quite far from that.