3

After migration, I have moved Magento from local server to live server, I get this error when I want to save any setting,

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY', query was: INSERT INTO `core_config_data` (`scope`, `scope_id`, `path`, `value`) VALUES (?, ?, ?, ?)
0
1

This is a pretty common issue due to how MySQL treats the auto-index values sometimes on imports from DB dump. Basically new store/website IDs have been created that do not match with other data.

Something like this would do the trick, remember to disable foreign key checks before and after the query, and to make sure the IDs match up with your existing data.

/* Reset core site/website */
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
INSERT INTO `core_store` VALUES (0, 'admin', 0, 0, 'Admin', 0, 1);
INSERT INTO `core_store` VALUES (1, 'default', 1, 1, 'Default Store View', 0, 1);
INSERT INTO `core_store_group` VALUES (0, 0, 'Default', 0, 0);
INSERT INTO `core_store_group` VALUES (1, 1, 'Main Website Store', 2, 1);
INSERT INTO `core_website` VALUES (0, 'admin', 'Admin', 0, 0, 0, 0, '', '', '');
INSERT INTO `core_website` VALUES (1, 'base', 'Main Website', 0, 1, 1, 0, '', '', '');
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;

More details:

You could also disable this MySQL configuration and re-import your data again also.

0

same error message here. /* Reset core site/website */ doesnt help. after i enabled auto_increment the problem was gone:

ALTER TABLE `core_config_data`
    CHANGE `config_id` `config_id`
    INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Config Id';

but i cant say if this solution has other problems.

2
  • thanks , this worked for me. i enabled = > problem solved, again i disabled it.... – Baby in Magento Jan 10 '18 at 5:48
  • Does not work, there is a warning – Black May 23 '18 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.