This post has been marked as old. The code might no longer work. Comments have been disabled as this is no longer maintained.
I build most of my client’s sites on my server, then move it to theirs when it is time to launch. After doing it many times, I have developed a set of steps that helps me do the move quickly and with minimal issues.
First, what not to do: Don’t use WordPress’ Export tool (Tools > Export, from the WordPress Administration area). This often results in lost content and images that don’t work – they get put in the wrong uploads subfolder, making them not show up on your site.
If at all possible, you’ll want to actually move the database, make a few changes to the database, then move the server’s files over.
This should only be done by experienced developers. You can lose your files and content forever if you do something wrong, so make sure to always have a backup.
Move your database
On the server with the site you’re moving (which I’ll refer to as “old server”), find PHPMyAdmin in CPanel, Account Center, or whatever else your host provides for managing your website. Once inside PHPMyAdmin, do the following:
- On the left side, click the database that your WordPress site is using (if you’re unsure, look in your wp-config.php file at
- On the top menu, click “Export”
- If this database is used only for this WordPress installation, just make sure “Save as File” is checked at the bottom and press “Go”. If you’re using the database for multiple WordPress websites, at the top-left select the tables used for this website (if you’re unsure, look in your wp-config.php file at
- Note: if your table prefix is wp_ you should change it to something else. This is better for security, and also will prevent issues importing it into the new server. Here’s how to rename your tables.
That will export a copy of your old server’s database to your computer. Next, you’re going to upload the database to your new server. Log into phpMyAdmin on the new server, go to the database you’d like the tables added to, and click Import.
Update the Database
Now that you have the database from the old server on the new server, we have to make a few changes to it. We’ll be changing all the mentions of the old server to the new server.
I’m going to assume that your table prefix is wp_, that your old site was http://www.oldsite.com and your new site is http://www.newsite.com. Click the SQL link at the top to run the following commands.
[sql]UPDATE wp_options SET option_value = replace(option_value, ‘http://www.oldsite.com’, ‘http://www.newsite.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
UPDATE wp_posts SET guid = replace(guid, ‘http://www.oldsite.com’,’http://www.newsite.com’);
UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.oldsite.com’, ‘http://www.newsite.com’);
UPDATE wp_postmeta SET meta_value = replace(meta_value, ‘http://www.oldsite.com’, ‘http://www.newsite.com’);[/sql]
- Update WordPress Options so the WordPress site knows where it is.
- Update the URL’s to the pages of your sites.
- Find any use of the old URL inside the posts (links, images…) and replace it with the new URL.
- Finally, find any use of the old URL inside custom fields (example: Thesis post image) and replace it.
Move the Files
All of your customizations to WordPress are stored in the wp-content folder, so that’s really all you need to move over. Copy the /wp-content directory from the old site and upload it to the new site. If you have SSH access you could also gzip the directory which will make the download/upload process go faster (moving one file instead of many).
Now your site has successfully been moved over. The only thing left to do is update the Permalinks and Privacy settings:
- Go to Settings > Permalinks and click Save Changes. This will create the .htaccess file so all permalinks will work.
- Go to Settings > Privacy and set the site to visible. This is only necessary if, when you first set up the site on your server, you unchecked “make this site visible to search engines”. I recommend keeping the site invisible until you deploy it.
To summarize, a Migration Checklist
- Download a copy of /wp-content and database.
- Upload database to new server.
- Find/replace domain.
- If an existing WP install is on the server, upload the /wp-content directory as /wp-content.new
- If an existing WP install is on the server, rename /wp-content to /wp-content.old. Rename /wp-content.new to /wp-content
- If a new WP install, upload WordPress to the server
- If a new WP install, delete the default /wp-content directory and upload the new one
- Update wp-config.php with new database credentials and change the SALT keys
- Log in and create permalinks (Settings > Permalinks, Save)
- Turn Privacy mode off