MySQL error 1062 - Duplicate Entry

  • 3532552
  • 03-Mar-2008
  • 16-Mar-2012

Environment

Novell Open Enterprise Server (Linux based)
Novell NetWare 6.5 Support Pack 6

Situation

MySQL duplicate entry errors can occur for a number of reasons. Attempting to add a record with a duplicate value in a primary key is the most common. View your table structure with PHPMyadmin or whatever client you prefer to ensure that it is correct.

Resolution

If you have verified the table structure and cannot see a duplicate entry, you may need to rebuild your table indexes. For details on rebuilding your table:
If you are using an auto-incrementing field as a primary key, check the data type of this field. An example of a problem of this type would be using the tinyint data type on the key. This data type can only handle up to 127 values before you would begin to see duplicate entry errors. Check the following table for the maximum values of each data type.