Duplicate Entry Errors


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


This error occurs 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.


We recommend dropping the problematic restored database and then working with your system administrator or database administrator to resolve the issue.

Last modified: June 11, 2024