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

Leave a Comment


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>