mysql auto_increment by 5?

后端 未结 3 2009
予麋鹿
予麋鹿 2020-12-06 15:01

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

I have a primary key, \"id\". It\'s set to auto increment. Problem is, first entry started at \"

相关标签:
3条回答
  • 2020-12-06 15:04

    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
    
    0 讨论(0)
  • 2020-12-06 15:13

    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.

    0 讨论(0)
  • 2020-12-06 15:19

    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 讨论(0)
提交回复
热议问题