Meaning
MySQL rejected the write because it would create a duplicate value.
Causes
- Inserting a row with a duplicate unique key
- Concurrent inserts for the same unique value
- Missing ON DUPLICATE KEY handling
Fixes
- Use INSERT ... ON DUPLICATE KEY UPDATE
- Check for duplicates before insert
- Serialize or de-duplicate concurrent writes
Example
ERROR 1062 (23000): Duplicate entry 'foo@bar.com' for key 'users.email'
FAQ
- Is this the same as unique violation?
Yes, it is MySQL's duplicate key error. - Should I remove the index?
Only if duplicates are allowed by design.
Contact
Contact your DBA if you need to adjust constraints.