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
DB_NAME) - 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
$table_prefix). - 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
Oliver says
Nice work thx, that worked for me!
Bill Scheider says
Hey Bill,
I only started following you a week ago or so and, with this, you’ve already saved me a ton of work and anxiety! 🙂
Thanks so much for this tutorial.
Thauna says
Awesome! Just what I needed!
melanie says
Okay…Brilliant!…I had developed a new wordpress site for one of my existing clients with a static website. I used a subdomain on my site to do it all. Was a little worried about the move because the import/export in wp sucks…
The only issue I had was the permalinks needed to be reset (I forgot to copy the .htaccess file). Once I copied that and refreshed…all was up.
I especially love the sql command replacing all the oldurl to newurl…worked like a charm.
Bill Erickson says
Thanks for the reminder. I always update the permalinks, but forgot to include it in the post. Updating the post now.
Stacey says
I’ve followed all the instructions to the letter but my permalinks have broken… Luckily, it’s just a localhost test before I attempted to do this on the live server but I’d like to know if there are any other tricks to get the permalinks to work again. I did switch them to the default structure (which works, of course) but no other permalink structure works.
Other than this small hiccup, your method works perfectly and it’s so simple! I was stressing out about the database move but now my only concern is if my custom permalink structure is going to work.
Bill Erickson says
Once migrated, did you go to Settings > Permalinks and click “Save”? After you migrate, you’ll need to regenerate the .htaccess file
Stacey says
Hi Bill. Thanks for answering so quickly. Yes, I did regenerate the file. I actually found out that in a localhost environment there is a mod_rewrite restriction that prevents the .htaccess file from doing what it needs to do to work.
I cloned the site on my server as a test and found that your instructions worked just fine the way they were and that it was limited to my local machine only.
Thanks for the great tutorial!
Rune Stangeland says
Thanks Bill! Everything worked as planned. Had a minor problem due to a plug-in and upgrading, but deleted the plug-in and everything works fine now.
paul says
have you given backupbuddy a try? it makes it really trivial to move a WordPress site from dev to live.
there’s a free alternative I’ve yet to test caleld “backup and move”
have you already moved a network install sub-blog to a single install?
Bill Erickson says
I prefer to work directly with the database, so if anything goes wrong I can figure it out and fix it. But that’s just a personal preference. I’ve heard great things about BackupBuddy.
Jason Pelker says
I can second the Backup Buddy method (I actually like to call the plugin, “Migration Buddy”). It also now allows migration to and from Multi Site installs.
marco says
“Log into phpMyAdmin on the new server, go to <> you’d like the tables added to, and click Import.”
Thing is, there is none..on my new server. Make one? then if so..does it need to be named the same as the other db on the old server, AND- same user name for the db, etc? Why wasn’t this mentioned? Sorry for the noobness.
marco says
go to the DATABASE, you’d like..
Bill Erickson says
Correct, you can log into the database in any manner you like. Because phpMyAdmin is so common I tailored my instructions for it. I personally connect to databases using Sequel Pro: http://www.sequelpro.com/
Patrick McKowen says
Question re: running the commands to update the database domain mentions:
I have developed the site in a directory on the “old site” (my domain) but moving it to the root folder of the “new site” (client domain).
Would I modified the mentions of ‘http://www.oldsite.com’
to
‘http://www.oldsite.com/folder-name’
This is my first time working directly with myPHPAdmin, so I really appreciate your instructions.
Many thanks!
Bill Erickson says
Yep, whatever the URL that’s in Settings > General > Site URL, use that.
Corey says
Sorry if this is obvious, but what I need to accomplish is moving an established blogspot site to wordpress without breaking 50,000+ backlinks.
Is the step in this process where you discuss the .htaccess file, the relevant piece of the puzzle that ensures all your backlinks still work once you are moved over?
Thanks for your time, I really appreciate this. I’m really glad I found your site!
Corey
Bill Erickson says
If your website is .blogspot.com then there’s no way to make those links work. To my understanding blogspot won’t allow you to forward that traffic to your own domain. If you’re already using your own domain you just need to match up the permalink structure so WordPress will construct the URLs in the same way as Blogger. Go to Settings > Permalinks to set this up