Mysql Specify Slave Database And Table

Server environment

1
2
3
4
5
$ cat /etc/issue
Ubuntu 16.04 LTS

$ mysqld --version
mysqld Ver 5.7.22-0ubuntu0.16.04.1 for Linux on x86_64 ((Ubuntu))

Before this tutorial, your database whatever master or slave , should be connected and synchronize successful.
About the slave config, you can find on this blog.

Specify the master database which should be synced

1
2
3
4
5
6
7
8
[mysqld]
...
# The binlog about this database named 'website' will be sent to all slave mysql
# If you do not specify this option, all database's binlog will be sent out
# Using ',' as delimiters to specify multi database
binlog-do-db = website
# Ignore be synced
binlog-ignore-db = performance_schema, information_schema

Configuration in slave mysql

  • Only Sync Database In Slave
1
2
3
4
[mysqld]
...
# Synchronize the specified database
binlog-do-db = website, app
  • Sync Tables In Slave
    1
    2
    3
    4
    5
    [mysqld]
    ...
    replicate-do-table = website.user
    replicate-do-table = website.article
    replicate-do-table = app.message
Share