开发者

mysql auto_increment by 5?

开发者 https://www.devze.com 2023-01-08 06:00 出处:网络
I\'m running into a really, really, really weird problem with mysql. I have a primary k开发者_如何学Pythoney, \"id\". It\'s set to auto increment. Problem is, first entry started at \"3\". And every

I'm running into a really, really, really weird problem with mysql.

I have a primary k开发者_如何学Pythoney, "id". It's set to auto increment. Problem is, first entry started at "3". And every new entry increases by 5, so the next entry's id is 8, the next is 13, then 18, so on. This is stupid. Why isn't it just incrementing by 1, like it should be? And why is it starting at 3???

Is there some setting somewhere I'm missing? I'm using phpmyadmin, if that helps.


There's a my.cnf configuration for that: auto_increment_increment. It's used for master-master server setups to prevent the same key from being defined twice by two different servers. So using that coupled with auto_increment_offset, it allows each server to always generate unique ids...

So, from what you're describing, it sounds like you have this:

auto_increment_increment = 5
auto_increment_offset = 3


The auto increment is probably set to 5. Try:

ALTER TABLE YourTable AUTO_INCREMENT = 1;

You can retrieve the current setting with:

SHOW TABLE STATUS LIKE 'YourTable'

See the MySQL docs for more details.


it appears the table was created with an increment set to 5. you can change it back to one with the following:

ALTER TABLE tbl AUTO_INCREMENT = 1;
0

精彩评论

暂无评论...
验证码 换一张
取 消