Help Center

Troubleshooting 'Duplicate Entry '0' for Key 'PRIMARY' Error: Step-by-Step Guide

Duplicate entry '0' for primary key error troubleshooting, Fixing primary key duplication issue, Resolving duplicate entry error in database 1
Print

Symptom

You may encounter the following error after copying a MySQL database containing WHMCS data to a new location, or restoring a database backup:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY' in /path/to/whmcs/vendor/illuminate/database/Connection.php
 

Cause

This error occurrs when the primary key and auto_increment attributes are absent from one or more tables in the WHMCS database.
Most tables in the WHMCS database will have these attributes on one of the fields.

During the import of the MySQL database table structures at the new location, some data was omitted or an error occurred on the SQL server, resulting in the required structural data failing to copy or restore correctly.

Solution

We recommend dropping the problematic restored database and then working with your server/database administrator for assistance migrating/restoring the database again.

Ensuring that the restoration is performed in such a way as to appropriately restore all the required attributes to the table structure within your WHMCS MySQL database.

 
 
The End! should you have any inquiries, we encourage you to reach out to the Vercaa Support Center without hesitation.

Was this answer helpful?

Still need a hand?

Our support team is on standby if this article didn't fully answer your question.

« Back