(1)错误情况
在slave上已经有数据表test,而master上并没有这张表,现在在master上新建test表,则slave上的复制过程会出错。
MySQL的log记录中相关信息如下:
2017-08-15T04:24:30.337730Z 11 [ERROR] Slave SQL for channel ‘‘: Error ‘Table ‘test‘ already exists‘ on query. Default database: ‘test‘. Query: ‘create table test(name2 varchar(100))‘, Error_code: 1050
2017-08-15T04:24:30.337809Z 11 [Warning] Slave: Table ‘test‘ already exists Error_code: 1050
2017-08-15T04:24:30.337819Z 11 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log ‘mysql-bin.000007‘ position 1289
(2)重现出错场景
(a)在slave上提前建立数据表test。
mysql> create table test (name varchar(100));
Query OK, 0 rows affected (0.02 sec)
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| data |
| data2 |
| t1 |
| tablename |
| test |
+----------------+
5 rows in set (0.00 sec)
(b)在master上建立数据表test。
mysql> create table test(name2 varchar(100));
Query OK, 0 rows affected (0.02 sec)
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| data |
| data2 |
| t1 |
| tablename |
| test |
+----------------+
5 rows in set (0.00 sec)
mysql> insert into test (name2) values (‘001‘), (‘002‘) , (‘003‘);
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
(c)查看slave上的数据表。
mysql> show create table test;
+-------+-------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------