Logo Background RSS

MySQL Error: 1062 Duplicate entry ‘0′ for key 1

Advertisement

  1. #1 Afrasyab Bashir
    July 11th, 2008 at 12:12 am

    Above normally means that there already exists an entry in the database that already has the value which autoincrement is trying to initialise with. So if duplicate entry ‘0′ is there then probably auto_increment value is trying to initialise with 0. I received the error duplicate entry ‘1′ for key 1, which strangely meant that the column already have a value 0 which the auto_increment index was trying to initialise. I had to change this value to the last value then changed the column to cater for auto_increment then re-initalise the counter to the last value and then revert the last value of my column back to it’s beginning value i.e. 0. (am i confusing you? ;)

    Post ReplyPost Reply
  2. #2 vinu
    July 12th, 2008 at 12:03 am

    Thanks for pointing that out Afrasyab. So this situation could happen when the auto-increment count goes wrong for some reason.

    Post ReplyPost Reply
  3. #3 Tony
    August 7th, 2008 at 8:45 pm

    I have the same problem, out of the blue got this error”
    :Duplicate entry ‘4853′ for key 1
    and I am using “int” as the data type. changing it to bigint may resolve things by resetting the autoincrement for the time being, but I expect it will surface again sometime. There is some other cause for this

    Also, it seems not a good idea to use bigint because extra disk space use ref: http://ronaldbradford.com/blog/bigint-v-int-is-there-a-big-deal-2008-07-18/

    Post ReplyPost Reply
Leave a Comment