Tag Archives: MySQL

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.