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
# Mysql

Thank you for reading.
This post is copyrighted by Liyuliang’s Blog.
If reproduced, please indicate the source: Liyuliang’s Blog
This blog uses Creative Commons Attribution-NonCommercial-Share-Sharing 4.0 International License Agreement to license.


Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×