There are two mysql servers A and BA: Creating & quot; STATEMENT & quot; B: auto_increment_offset1auto_increment_increment2A and B. The table creation statements are as follows: test | CREATETABLE 'test' ('id' int (11) NOTNULLAUTO_INCREMENT, mysql
Two mysql servers A and B
A: auto_increment_offset = 2
Auto_increment_increment = 2
Binlog_format = "STATEMENT"
B: auto_increment_offset = 1
Auto_increment_increment = 2
Both A and B are shown in the following table. The table creation statement is as follows:
Test | CREATE TABLEtest
(
id
Int (11) not null AUTO_INCREMENT,
title
Varchar (45) default null,
Primary key (id
)
ENGINE = InnoDB default charset = utf8
Test1 | CREATE TABLEtest1
(
id
Int (11) not null AUTO_INCREMENT,
title
Varchar (45) default null,
Primary key (id
)
ENGINE = InnoDB default charset = utf8
The data in the test table is as follows:
+ ---- + -------------------------------------
| Id | title
+ ---- + -------------------------------------
| 2 | 2
| 4 | 2
| 6 | efe4aee2-e721-11e5-a858-000c2952edc5
| 8 | 08:31:18
| 10 | 08:31:40
| 12 | 97621dc2-e722-11e5-a858-000c2952edc5
| 14 | aaaq
| 16 | aaaq
| 18 | 13
+ ---- + -------------------------------------
Run the following SQL statement on server:
Insert test1 select * from test where id> = 10
Although mysql has a warning:
Unsafe statement written to the binary log
Using statement format since BINLOG_FORMAT = STATEMENT.
However, I can see that server B synchronizes the data of server A as follows:
+ ---- + ---------------------------------------- +
| Id | title |
+ ---- + ---------------------------------------- +
| 10 | 08:31:40 |
| 12 | 01b889cf-e721-11e5-9568-000c29aa710d |
| 14 | aaaq |
| 16 | aaaq |
| 18 | 13 |
+ ---- + ---------------------------------------- +
At this time, check the binlog log of server A and find
BEGIN
/*! */;
At 665994732
#160314 15:47:15 server id 136 end_log_pos 665994865 CRC32 0xeb828757 Query thread_id = 1675059 exec_time = 0 error_code = 0
Set timestamp = 1457941635 /*! */;
Insert test1 select * from test where id> = 10
/*! */;
At 665994865
#160314 15:48:38 server id 136 end_log_pos 665994896 CRC32 0x5a745662 Xid = 169785483
COMMIT /*! */;
Server A does not prompt how many IDs are inserted for auto-increment data. why are the data of server B and server A's
The data is still consistent.
According to your understanding, the data of server B should be as follows, because the id is generated by the self-growth of server B.
+ ---- + ---------------------------------------- +
| Id | title |
+ ---- + ---------------------------------------- +
| 1 | 08:31:40 |
| 3 | 01b889cf-e721-11e5-9568-000c29aa710d |
| 5 | aaaq |
| 7 | aaaq |
| 9 | 13 |
Thank you for your answers!