mySQL auto increment problem: Duplicate entry '4294967295' for key 1

后端 未结 7 860
-上瘾入骨i
-上瘾入骨i 2021-01-25 02:30

I have a table of emails.

The last record in there for an auto increment id is 3780, which is a legit record. Any new record I now insert is being inserted right there.

7条回答
  •  鱼传尺愫
    2021-01-25 02:58

    This usually happens when you accidentally insert a new record a provide the auto_increment value.

    Most of the time that's because you have a column with a similar name and you make a typo that leads to the auto_increment value updated with the one you provided, which is 4294967295 if you provided a string instead of an int.

    To solve this:

    • delete the record whose PK value is 4294967295,
    • check what was the max increment value by running
    select max(autoincrementColumNameHere) from tableNameHere
    
    • update your AUTO_INCREMENT value by running
     ALTER TABLE tableNameHere AUTO_INCREMENT = (maxValue+1)
    

提交回复
热议问题