Posted on September 29, 2009
Learn how to setup a live development environment using CodeKit & LESS.
Discover how to add a Media Queries toggle button to your site using jQuery.
Having Magento problems? This solution may help get you up and running again!
Learn how to make Polaroid-style images complete with 3D shadows using only CSS.
Discover how to make your own 3D box using gradients and shadows with the power of CSS.
The following article describes the processes and steps involved to successfully move your Magento site to a new server/domain name, along with some possible solutions for further issues you may encounter.
I used my Control Panel’s “site backup” feature here for two reasons: a) you have less to download, and b) you can be sure you have all the files intact when you deploy the other end. If you don’t have this feature with your host, you can manually download the files – but be sure to check you have everything and that there were no errors during the downloading process!
Also, if you have shell access to the server, you can zip up the whole lot and download in one go – this will make it easier to deploy on the receiving end, and will ensure none of the files are corrupted and/or go astray during the upload.
Once I had my package downloaded, I deployed to the new server – again, if you can, upload the zip package and extract via the server. If you are unable to do this, extract the package locally and upload the files manually (cue: cup of tea).
Using PHPMyAdmin, take a full backup of the site database that Magento was using. This should be in the form of a .sql file. Make sure you take a full backup of all the database tables. If the database is particularly large, use compression on the export (built-in to PHPMyAdmin) which will help keep within the file upload limits.
Working in PHPMyAdmin on the target server, simply import the SQL file into an empty database (you may need to create one first).
This needs to be done in two places in the database. Using PHPMyAdmin, select the table named core_config_data and locate the following database rows:
Note the text value for each entry – this corresponds to the root URL of the site. This should be confirmed as the data should reflect the current site’s root URL. To change, simply click the edit button for each of the two rows and input your new base URL value into the text box, saving when you’ve finished each one.
You can find your local.xml file in the app/etc directory.
Look through the file until you see the database connection information. If will look similar to the following:
Then change the values in the square brackets after the CDATA tags to your new database server settings, for example:
Once done, save the file.
Simply locate your var folder and delete all content within.
You may also need to manually deploy the .htaccess file from the old site to the new site – so if your links do not work on the new server, make sure .htaccess is present and correct.
If you are planning to update Magento Core, any modules, or add new extensions to your Magento site, you will need to correct this since the Connect Manager (/downloader on the server) references the old site, and the links are hard-coded into the files, making it practically impossible to update manually. There is also a real risk of accidentally updating files on the old server if running MagentoConnect (if the old site still exists).
The best way to sort this problem is this:
1. Delete or Rename the /downloader directory
Probably safer to rename this for the time being. You will need to do this via FTP or your control panel file manager.
2. Obtain a fresh copy of Magento
The version number will need to be the same as the version you are running on your site. Download the .zip file and extract locally to your computer.
3. Upload the "clean" /downloader directory
Once you have the extracted files from step 2, find the /downloader directory and upload it to your Magento installation.
4. Run MagentoConnect and perform a core update
You can leave this step for now if you prefer not to update your installation. This will check all core modules and update as necessary, and will also add the missing list of core modules back into MagentoConnect. Paste the following extension key into MagentoConnect Manager:
You can also do this for any extensions you have installed, which will also add them back into the list.
This could be caused by an error during the MySQL import and is possibly related to auto-increments on certain rows in the database.
Try this and see if it fixes the problem:
1. Logon to PHPMyAdmin.
2. Locate the following tables: "core_store", "core_store_group" & "core_website".
3. Note the "website_id" value for the admin code. It should have a 0 (zero) value; if not, change it to zero and save. Repeat this for all three tables.
Thanks for the help on this…. I copied my magento database using PHPMyAdmin for backup. When trying to copy back, I got the above error undefined index.
Just as clarification…
In core_website: code “admin” should have website id = 0
In core_store: code “admin” should have STORE_ID (and website_id) = 0
In core_store_group: name “Default” should have group_id (and website_id) = 0
That should fix it….it seems so far.
Sounds about right.
If in doubt, compare with the original database tables – they should be the same on both. If not, amend the new import with the old values. I’ve had this issue a few times and this always seems to resolve it.
Thanks for this neat procedure! I’m almost there!
Any idea why I have been able to correct mentioned table, except for core_store?
When changing admin from 1 to 0, I get : #1451 – Cannot delete or update a parent row: a foreign key constraint fails (`dite6021_testmagento/tag_relation`, CONSTRAINT `tag_relation_ibfk_4` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON DELETE CASCADE)
I’m afraid I’ve not seen this particular issue before – it could be something to do with the way the hosting and/or DB is configured. I would attempt to ask your hosting provider if they have any clues – failing that, a scour around Google may provide some help in figuring out what’s wrong.
Thanks for this useful article, I’d got most of the way but the cache caught me out until google brought me to you.
It is very annoying that magento makes this hard.
When I develop websites I routinely work on a local version and then deploy the changes to the live site (often via a staging site that the client can check before changes go live).
Magento is almost forcing users to risk breaking their sites every time they do anything substantial like loading a new extension etc. …or at least forcing them to do the whole thing twice and hope that they don’t do anything different the second time around.
I can script the cache clearing and the change to the core_config_data. The issues with MagentoConnect and the downloader are more alarming.
Currently all my product images have disappeared in the move and I can’t access the product list in admin even though it works in the front end. Ho hum… onwards…
Thanks for your comment Paul, and I agree 100% – it is frustrating (and alarming) as you say. And I find each time presents a new set of problems. It certainly adds a lot of time to a project when dealing with these issues.
A good tip when installing magento is use administrator rather than admin in the administration URL this will avoid problems down the line
I see that Magento now is quite useful for enterprises which want to build for themselves a professional website. However, installation process is very difficult to do.
i have clone a magento store , frontend is working fine , in backend when i enter login and password then it shows this link is broken , please help on this.
I have successfully configured Magento. Thanks for such great help.
Thanks for the useful information. You’re welcome to check out our article on the similar topic posted here http://www.atwix.com/magento/moving-magento-to-another-server/ and leave your feedback.
You are a boss. This got me out of a pinch. This is just the cat’s pajamas.
Pretty! This was a really wonderful post.
Thank you for providing this info.
[…] Moving a Magento Installation […]
Thanks alot for this tutorial, you saved my life!
in magento 9 no database configuration when you transfer the site
i mean magento 1.9
Mail (will not be published) *
Your comment *
I consent to Toolbox Digital collecting and storing my data from this form, as detailed in the Privacy Notice.
Previous: How to Delete Test Orders and Reset Counters in Magento
Next up: Hiding your WordPress development site on a live server
.htaccess Made Easy
by JEFF STARR
Buy Now »
Hardboiled Web Design
by ANDY CLARKE