In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Today, I will talk to you about how to understand the strange problems about AUTO_INCREMENT in the master-slave replication of MySQL. Many people may not understand it very well. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
Yesterday, I modified the field of a table and found that the master-slave replication synchronization had failed, but there was no error in the synchronization process and there was no error in the mysql log. I carefully looked into the reason and found that the starting value of the newly added primary key field was inconsistent on the master and slave database, resulting in the corresponding record cannot be found in the slave database when the data was updated by the primary key. The story is as follows: [@ more@]
Table table1 (master library is innodb type, slave library is MyISAM type), there is a self-increasing primary key pid, now the pid is changed to non-self-increasing, non-primary key, plus a self-increasing primary key.
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 the table table1 on the main library is automatically gone, and the default starts from 1, but the auto_increment attribute of the table table1 on the slave library also has the maximum value of the previous pid.
The strange thing is that I did not have this problem when I changed the library to innodb. I suspect that it is the bug of mysql. Record it here and pay attention to it later.
After reading the above, do you have any further understanding of how to understand the strange question about AUTO_INCREMENT in MySQL master-slave replication? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 239
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.