Search code examples
mysqlreplication

Mysql Replication, 2 databases, 2 ways?


I have 2 MYSQL server.

MySQL#1 and MySQL#2

MySQL#1 hosts a database which has been replicated thanks to this tutorial https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql to MySQL#2. Let's name this first database DATABASE1

MySQL#2 hosts another database DATABASE2 which has nothing to do with DATABASE1.

Is it possible to replicate as master-slave without creating conflict with the first replication, to let MySQL#1 becoming the slave for MySQL#2 ?

Thanks for any tips.


Solution

  • It is possible. I used to do that myself. There are several ways to do so.

    1. At slave server configuration file, add replicate-ignore-db = DATABASE_YOU_WANT_TO_IGNORE
    2. At master server configuration file, only log the database you want replicate to slave. binlog_do_db = DATABASE_YOU_WANT_TO_REPLICATE

    Not only you can specified what database to repliace, you can even specified only what table in particular database that you want to replicate. See also replicate_wild_do_table

    Further Reading