Migrating WordPress to a New Server

Somehow, I have ended up with my WordPress installations scattered over three different hosting accounts. This has been bothering me for a while, as I’m paying for three separate hosting accounts and I only need to be paying for one. To start the process, and as a form of catharsis, I thought I’d write a tutorial about how to migrate from one host to another. That way I feel like I’m doing something useful while actually I’m doing something boring.

To start with, I want to move my sites from GoDaddy to HostGator (my other sites are on Coolhandle who are even more useless than GoDaddy but I’ve got to start somewhere).

Before you get started it’s a good idea to tell anyone who works on the site that you’re migrating it and they should not make any changes to it until the migration is complete.

1. Backup your Database

First of all make a backup of your database. If you’re working on GoDaddy or something similar you’ll find your MySQL DBs under Databases > MySQL

Click the database you want to back up and enter the login details. Make sure you change your database type to English (UTF-8) when you log in.

insert your database username and password

Tip: If you can’t remember your database password you’ll find it in your wp-config.php file

Click on your database.

select the database you want to migrate

At the top you’ll see a tab that says “Export” click here.

click the export tab

Now you’ll be presented with options of what you wish to back up. Make sure that all of your database tables are selected, along with SQL.

Under Structure, make sure that the following are selected:

  • Structure
  • Add DROP TABLE / VIEW / PROCEDURE / FUNCTION
  • Add IF NOT EXISTS
  • Add AUTO_INCREMENT’
  • Enclose table and field names with backquotes
structure settings ticked

Make sure the “Data” checkbox is ticked.

Ensure the main data option is checked

You should end up with something that looks a bit like this:

MySQL Settings

Select “Save as File” and then click “Go

Choose "none" for compression and click go

Your database will back up. It may take a few minutes, depending on the size of your database.

Featured Plugin - WordPress Google Maps Plugin

Simply insert google maps into posts, sidebars and pages - show directions, streetview, provide image overlays and do it all from a simple button and comprehensive widget.
Find out more

2. Create Your New Database

Now I’m going to hop over to Hostgator where I’ll create my new database.

Log in to CPanel (or Plesk) on your new host and look for where you can create a new MySQL database. In Hostgator it’s about 2/3rds of the way down the page. Click on “MySQL Databases”.

click on mySQL databases

Add the new database name.

create your new database, calling it whatever you like

Add a database user, or add an existing user to the database. I’m going to use one that I’ve already created.

add a new or existing user to your database

3. Import Your Site’s Database

Once you have created your user return to your CPanel homepage. Scroll down until you find phpMyAdmin.

click on PHPmyAdmin

Click on the database that you want to access.

select the correct database

Look for the import tab at the top bar.

click the import tab

Browse for the file you want to import. Leave the character set as utf-8.

browse to the correct file

Make sure the Format is set to SQL. Click “Go.”

Leave it to do its thing.

Once it’s ready it’ll let you know. Your database for your site now has a new home on your new host (which isn’t stupid GoDaddy – w00t!)

completed import

Tip: if you are using a host which allows outside access to your MySQL databases you can use a trick from Vladimir Prelovac to avoid any downtime to your site. Unfortunately, it’s not going to work with Hostgator.

Featured Plugin - WordPress Membership Site Plugin

If you're thinking about starting a paid, or just private, membership site then this is truly the plugin you've been looking for. Easy to use, massively configurable and ready to go out of the box!
Find out more

4. Download your Site

Open up your favorite FTP program and navigate to your site. Download all of the files onto your computer. This might take a while – go make a cup of tea!

download your site using your favourite FTP program

Open up wp-config.php and update the MySQL details with your new database.

You will need to change the following:

  • Db_name
  • Db_user
  • Db_password
  • Db_host
New MyConfig file with edits to line 19, 22, 25, and 28

5. Upload Your Site

With your new wp-config.php details inserted you’re ready to upload your site onto your server. Using your FTP program drag and drop the files you want onto your server.

upload your site to your new host

6. Change Your Nameservers

Unless you have transferred your domain to your new hosting company, you’ll need to update your nameservers. This process can take anything from 2 hours to 48 hours.

Log into your Domain Manager. Select the site you want to edit and then click “Nameservers”

select the site you want to edit and the click "edit nameservers"

Click “Set Nameservers”.

click set nameservers

You will get your new nameservers from your new host. When I signed up with Hostgator they came with the account info email.

add your nameservers

Wait!

My site took about 10 minutes to transfer the nameservers – so you might be lucky! You can do a Whois lookup on DNS Stuff to see if your nameservers have moved.

whois lookup showing new nameservers

And that’s it – your site is moved to your new host. Easy! Now I’ve only got another few dozen to do….

It gets a lot more complicated if you want to change your site’s domain. Want me to cover that too? Let me know in the comments – otherwise check out the WordPress Codex!

Featured Plugin - WordPress Facebook Plugin

Would you like to add Facebook comments, registration, 'Like' buttons and autoposting to your WP site? Well, The Ultimate Facebook plugin has got that all covered!
Find out more

Comments (25)

  1. Great stuff, but moving a multisite is more difficult – even the codex says so….any tips there, from dev folder to root, or over to another server – both are fraught with difficulty – unless someone knows different, or there is a magic plugin somewhere..I wish..:-)

  2. sweet! this tutorial is going to be very handy.

    hey – just out of interest – why are you moving from GoDaddy?

    when I signed up a few years ago they were excellent – but in the last year or two I’ve had frequent latency & downtime issues which GoDaddy has not resolved for me.

    would you recommend Host Gator?

    cheers

  3. imacg: Same boat. Full of holes. Been trying options for two weeks with varying degrees of success. Complicated by going from Linux to Windows IIS.
    I can get the data transferred, and see it all in phpmyadmin, but can “fix” the base tables to recognize any of it.
    If you find a solution, please share / email.

  4. Nice one, a great tutorial for the beginner :)
    I do the same for the database (using phpmyadmin). I copy the files directly between the server using rsync. The way is much faster, after I’ve changed the database settings On the new server), it’s time to change the DNS.
    I noticed that Super-Cache needs a new path too: just disable/enable the plugin and the path is updated (you need to restore the other settings after that)

  5. Migrating when there is alot of serialized data in wp_options as well as wp_postmeta is what I am curious about, I always have issues when I have a site with plugins that utilize serialized data, especially when migrating from a dev environment to live. Any tips, pointers or tools to ease the pain?

    Thanks!

  6. Great Tutorial Thanks! I always follow a similar process for moving a WP installation from localhost (for development) to stage (domain 1) and then to live (domain 2) – So there’s a lot of moving ;) My questions is, when moving I always download the DB, open in Notepad then do a search and replace for the old domain, new domain in the SQL DB, save and then upload this “new” DB so that all links, images, etc work. Once uploaded all I usually have to do is update to permalink structure to write the .htaccess again and everything is 100%. Is this the right (optimal) way to do this?

  7. Thanks for the great how-to article. It’s the best I’ve seen on the subject. The annotated screenshots are do a wonderful job of highlighting the relevant action needed. It will be the reference that I’ll point people to when they need help on how to move a WP site.

Participate