指定同步库情况
1、binlog_format= ROW模式
mysql> use testdb;
Database changed
mysql> show tables;
+------------------+
| Tables_in_testdb |
+------------------+
| test01 |
| test1 |
+------------------+
3 rows in set (0.00 sec)
mysql> insert into test1 values('zhng','man');
Query OK, 1 row affected (0.05 sec)
mysql> insert into test1 values('meimei','woman');
Query OK, 1 row affected (0.04 sec)
mysql> select * from test1;
+--------+-------+
| id | name |
+--------+-------+
| zhang | man |
| zhng | man |
| meimei | woman |
+--------+-------+
3 rows in set (0.00 sec)
从库查看
mysql> use testdb;
Database changed
mysql> show tables;
+------------------+
| Tables_in_testdb |
+------------------+
| test01 |
| test1 |
+------------------+
2 rows in set (0.01 sec)
mysql> select * from test1;
+--------+-------+
| id | name |
+--------+-------+
| zhang | man |
| zhng | man |
| meimei | woman |
+--------+-------+
3 rows in set (0.01 sec)
2、binlog_format= STATEMENT模式
主库配置如下
binlog-do-db = testdb
从库配置如下
replicate-wild-do-table = testdb.%
主库操作
mysql> create database testdb;
Query OK, 1 row affected (0.01 sec)
mysql> use testdb;
Database changed
mysql> create table test01 (
-> id varchar(10) not null,
-> name varchar(10) not null
-> );
Query OK, 0 rows affected (0.04 sec)
mysql> insert into test01 values('zhang','man');
Query OK, 1 row affected (0.01 sec)
mysql> select * from testdb.test01;
+-------+------+
| id | name |
+-------+------+
| zhang | man |
+-------+------+
1 row in set (0.00 sec)
从库查看
mysql> use testdb;
Database changed
mysql> select * from test01;
+-------+------+
| id | name |
+-------+------+
| zhang | man |
+-------+------+
1 row in set (0.00 sec)
测试在不指定忽略库的情况下默认库是否会同步数据
mysql> create user testdb_user;
Query OK, 0 rows affected (0.03 sec)
mysql> select user from mysql.user;
+-------------+
| user |
+-------------+
| testdb_user |
| mysql.sys |
| root |
+-------------+
[root@mysql-s ~]# mysql -uroot -p -e "select user from mysql.user;"
Enter password:
+-----------+
| user |
+-----------+
| mysql.sys |
| root |
+-----------+
注:默认的库的数据没有被同步