Moving Magento from one server or domain to another

I’ve gleaned this info from the Magento forums and from which has now gone offline.

Thanks to Branko for his original post.  (If you see this I hope it was ok to re-post but I could get in touch because your site went offline!).  I was able to grab it from Google Cached.

I’m posting it here just for my own notes and to help anyone else struggling with moving Magento from on server to another.

Moving Magento from one domain or server to another

Export using default settings of phpMyAdmin.

Moving a database should be a simple two step process.

Step 1: Export your database to a file.

Step 2: Import your database from a file to new MySQL server.

Now doing it for Magento

First, make a backup of entire Magento database with all the default phpMyAdmin options.

Backup your database to .sql file.

Let’s suppose your development site is located at and your live site is located at

Second step for you would be to open the backup file you created at first step and do Search/ReplaceAll from “” to “”.

Magento stores complete url paths inside the database. Therefore you’ll end up with database full of url paths. My backup file had total of 17300 occurrences of “”.

If you search/replaced your .sql file do not rush to import it.

If you try to import file as is, you’ll most likely get some errors from MySQL concerning foreign key constraint an so on.

Important steps

Place these lines of SQL code on very top of the .sql file:


Place these lines of SQL code on very end of the .sql file:


Now you’re ready to import your .sql file to live MySQL database.

I suggest you ZIP your .sql file and then do import of .zip file trough phpMyAdmin.

Your upload will be faster.

For example my .sql file was 4MB in size while .zip was 300KB. During the import you should not get any error messages.

Ok, for now you should have copied entire root folder content of your Magento from to root folder of There is only one more thing to do before you can open you’re page in browser.

Having in mind that the root of your Magento is you now need to open file and modify it’s database connection information accordingly to your new database in

Save the changes open your browser to

Your Magento should be working!

Extra notes

This guide should get you up n running if you’re moving you’re site from one hosting to another.

There are few more things to keep in mind it the site is not working.

First you need to check folder write permissions through FTP.

Folders like /app, /app/etc, /var, /var/log, /var/session and so on, need to have appropriate access rights (755, 775, 777). Play around with it. There is one more thing that can cause problems. That is .htaccess file. If you’re moving a file from one site to another, and dumping it into same folder, then you probably won’t need to change this. But if you’re dumping it into some sub folder like then you’ll have to write following into .htaccess file “RewriteBase /products/” and don’t forget your .sql Search/replace all to set it now replace of “” with “” since you’re dumping Magento into sub folder.

Dave Walker
Dave Walker is a middle aged programmer living in North Yorkshire, who loves music and used to enjoy constantly restarting fitness regimes with a bit of football, cycling, swimming & jogging. Now I just eat biscuits.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.