I tried to migrate/transfer my live site to localhost. I am using WAMP and I imported the database via phpmyadmin, Problem comes up after i process the configuration process(after filling database information)

i got error SQLSTATE[23000]: Integrity constraint violation: 1022 Can't write; duplicate key in table and error log as below:

a:5:{i:0;s:239:"Error in file: "C:\wamp\www\localsite\app\code\local\amam\Conf\sql\amconf_setup\mysql4-upgrade-3.2.2-3.3.0.php" - SQLSTATE[23000]: Integrity constraint violation: 1022 Can't write; duplicate key in table 'amam_amconf_product_attribute'";i:1;s:940:"#0 C:\wamp\www\localsite\app\code\core\Mage\Core\Model\Resource\Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...')
#1 C:\wamp\www\localsite\app\code\core\Mage\Core\Model\Resource\Setup.php(437): Mage_Core_Model_Resource_Setup->_modifyResourceDb('upgrade', '1.0.0', '3.9.11')
#2 C:\wamp\www\localsite\app\code\core\Mage\Core\Model\Resource\Setup.php(320): Mage_Core_Model_Resource_Setup->_upgradeResourceDb('1.0.0', '3.9.11')
#3 C:\wamp\www\localsite\app\code\core\Mage\Core\Model\Resource\Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()
#4 C:\wamp\www\localsite\app\code\core\Mage\Core\Model\App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#5 C:\wamp\www\localsite\app\code\core\Mage\Core\Model\App.php(343): Mage_Core_Model_App->_initModules()
#6 C:\wamp\www\localsite\app\Mage.php(684): Mage_Core_Model_App->run(Array)
#7 C:\wamp\www\localsite\index.php(87): Mage::run('', 'store')
#8 {main}";s:3:"url";s:11:"/localsite/";s:11:"script_name";s:20:"/localsite/index.php";s:4:"skin";s:7:"default";}

where "amam" is an extension folder name. Thanks for anyone trying to help!


2 Answers 2


Solution: Spent days to find that the problem is JUST - u need correct data in app/ect/local.xml (i.e. admin_name, database_name..etc) but NOT to delete it!

If you deleted the local.xml, the magento installation process will run (so yo u can fill in admin and database info), but at the same time it also create unnecessary tables i.e. my original table is xgj_core_config_data (dunno why there are prefix), but the process also created the default ones: core_config_data (without the prefix), which finally leads the duplicate keys error.


Basically when you migrate a site and want to change the domain for the site, there's a couple things that you need to do.

For starters, let's say you're going from mysite.com to local.mysite.com (that way if you've got a wildcard SSL cert you can still use it locally). Assuming you've got Apache all set up for local.mysite.com, what you need to do in Magento is

1) Update the DB parameters and if necessary, your redis/memcache parameters in local.xml. While you could delete local.xml and rerun the installation, it's a text file so you can just edit the fields and you're golden. For me, I have to strip out all the Redis caching/session stuff since I don't have a local Redis instance and then update the DB host settings.

2) Log into the DB that you're local installation is going to use and run

SELECT * FROM core_config_data WHERE value like '%mysite%';

I like to do it with the wildcards just so that I can see what all is tied to the mysite.com domain. But you should see in your search results a couple lines where the path column is web/unsecure/base_url and web/secure/base_url. Then you'll need to update those lines to 'http://local.mysite.com/' and 'https://local.mysite.com/' respectively. Don't forget the trailing slash though!

3) Flush your cache. This could be anything from deleting the contents of var/cache and var/session to flushing memcache or redis as appropriate.

And that should be it. Point a browser to local.mysite.com (assuming, if needed, that you've got a hosts file entry that points local.mysite.com to and your site should load on your new local installation!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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