phrants.net
2Fév/100

#1062 – Duplicate entry ‘1’ for key 1

This error kept popping up on me in myPhpAdmin while working with a mysql database. It was driving me up the wall as I didn't want to re-create the table just to assign a primary key and set auto-increment in an empty table. The first problem I noticed was that there was more than one "1" in the table. Makes sense, obviously you can't set the primary key in a column where there are duplicate entries. The second piece of the puzzle, however, was much more difficult to identify. It turns out that myPhpAdmin won't allow you to set auto_increment to a column where there is a "0" (zero) as unique key. I changed the zero to a 999 and then was able to set the auto increment. Then I went back in and manually changed the 999 back to zero. I couldn't find this solution anywhere else online, so I thought I would share it here.

Commentaires (0) Trackbacks (0)

Aucun commentaire pour l'instant


Laisser un commentaire


Aucun trackbacks pour l'instant