- Plesk for Linux
- Plesk for Windows
When adding a customer, subscription, mail account, mailing list, IP address, installing Let's Encrypt SSL or changing domain hosting type or installing an SSL certificate in Plesk, the operation fails with:
PLESK_ERROR: Error: DB query failed: SQLSTATE: Integrity constraint violation: 1062 Duplicate entry '34' for key 'PRIMARY', query was: replace <table_name> set ...
When installing a custom instance of WordPress at Domains > example.com > WordPress > Install > Install (Custom), the operation loads continuously and no errors appear.
AUTO_INCREMENTvalue for the table from the error message is equal or less than max PRIMARY KEY value of this table:
# plesk db -Ne'SELECT CONCAT("Auto increment value: ", AUTO_INCREMENT) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = "psa" AND TABLE_NAME = "DomainServices";'
Auto increment value: 45
# plesk db -Ne'SELECT CONCAT("Primary key name: ", COLUMN_NAME) FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = "psa" AND TABLE_NAME = "DomainServices";'
Primary key name: id
# plesk db -Ne'SELECT CONCAT("Max value: ", MAX(id)) FROM DomainServices'
Max value: 46
Note: The command
plesk db -Nedoes not work on Windows Server 2012. It is required to first Access Plesk database and execute the queries.
The AUTO_INCREMENT value for the table is lower than the real maximum PRIMARY KEY value.
This issue could be caused when InnoDB and XtraDB use an auto-increment counter stored in the memory. When the server restarts, the counter is re-initialized. This issue is mentioned for a certain MariaDB version.
Download and use the script to automatically update the improper AUTO_INCREMENTS value: