When I modified a table field yesterday, I found that the master-slave replication synchronization failed, but the synchronization process was not faulty, and the MySQL Log was not faulty. I carefully searched for the cause, it is found that the starting values of the newly added auto-incrementing primary key fields are inconsistent with those in the master/Slave database. As a result, the corresponding records cannot be found in the slave database when data is updated by the primary key. The procedure is as follows:
Table 1 (the master database is of the InnoDB type, and the slave database is of the MyISAM type) has an auto-incrementing primary key PID. Now, the PID is changed to non-auto-incrementing and non-primary key, and an auto-incrementing primary key is added.
Alter table Table1 modify PID int not null;
Alter talbe Table1 drop primary key;
Alter table Table1 add aid int not null auto_increment primary key first;
As a result, the auto_increment attribute of Table 1 in the master database is automatically unavailable. The value starts from 1 by default. However, the auto_increment attribute of Table 1 in the master database is still the maximum value of the previous PID.
The strange thing is that I have changed the slave database to InnoDB. I suspect it is a MySQL bug. Record it here and pay attention to it later.