Magento Error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘363624’ for key ‘PRIMARY’

Today I was setting up a Magento staging store. This is something I’ve done more times than I’d care to admit recently and as a result, have the process down to a fine art. However, just when I was congratulating myself on being such a top class legend, I browsed to the admin panel and came across an error I’ve never seen before in this context-

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '363624' for key 'PRIMARY'

Googling brought back many PHP related errors and it’s obvious to anyone who knows anything about databases that there’s a conflict between keys somewhere… somehow… Eventually I found the fix- Pesky logs.

Run the following SQL query on the problematic database

TRUNCATE dataflow_batch_export ;
TRUNCATE dataflow_batch_import ;
TRUNCATE log_customer ;
TRUNCATE log_quote ;
TRUNCATE log_summary ;
TRUNCATE log_summary_type ;
TRUNCATE log_url ;
TRUNCATE log_url_info ;
TRUNCATE log_visitor ;
TRUNCATE log_visitor_info ;
TRUNCATE log_visitor_online ;
TRUNCATE report_event ;

Job done!

Leave a Reply

Your email address will not be published. Required fields are marked *