ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry ‘1’ for key ‘PRIMARY’

I got this error while trying to add auto_increment attribute to a MySQL table field:

ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry ‘1’ for key ‘PRIMARY’

After some googling I found the solution: simply remove the record with ‘0’ for the primary key field. It seems that MySQL tries to adjust ‘0’ to ‘1’ for auto_increment field.

  1. Big thanks for this post! I got the same problem and fis it!

  2. 😛
    yes, the same problem, delete the data with a ‘0’ id, problem solved.

    thx

  3. problem solved, thanks

  4. thank you so much

Reply to Dmitriy ¬
Cancel reply


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.