Migrate Your Site Between Hosts

I would like to take you through my preferred method of migrating a WordPress site between hosting companies.

So if you are planning to move your site from one hosting company for cost or reliability reasons, then this post is for you.

Pre-Migration Tasks

There are a couple of control tasks I like to do before the migration begins.  I like to take some metrics so you know that the migration has been a success once you are at the target hosting company.  The details I take are:

Record number of blog posts, comments, categories,and pages.  This can be quickly collected from the dashboard.

Take screen dumps of major pages so you can check everything has been taken across and more importantly looks okay.

Document your widgets what codes you are using etc.  I have seen widgets die during a migration.

1) Stop All Activity on Your Old Hosting Company

This is cut off time, no more posting of editing until the migration is complete or you risk loosing data.  This is especially important if you are a mulit-writer blog setup.

2) Build A New Database On Your Target Hosting Company

On your new hosting company the first stage is to create a new blank database.  Most hosting companies have some sort of database creation wizard, build an empty database ready to accept your data.

You will need to record the database name, user name, password and host for use later in the process when you update your wp-config.php.

3) Backup the database

Go to your old hosting company and look for a tool called phpmyadmin, nearly every hosting company I have worked with has this tool, it enables you to create a dump fo your database.

Navigate to export, make sure you select all the tables and create a dump file.  Save this somewhere on your local machine.

Check out my series on backup and recovery for more details at https://ibraininc.com/backup-recovery-introduction

4) Using FTP copy all of your WordPress files

Connect to your old hosting  site using an ftp client (I always recommend using sftp to make sure your site is secure) and download all of the files from your site to your local machine.  This may take some time depending upon the number of files on your site.   If you have thousands of images or added files the download may take a couple of hours.

5) Restore your Database To the Target Hosting Company

Connect to your new blank database using phpmyadmin, and run an import process, again refer to the recovery section of this series of posts  https://ibraininc.com/backup-recovery-introduction

If you have issues at this point, don’t panic, your site is still live on the old hosting service, you can take your time and experiment with the export/import process.  Then when you are happy start the entire process again.

6) Upload your WordPress files

This is the reverse process of step number 4.  Using FTP copy all of the saved files from your local drive up to your new hosting account.

The files should be copied to your http root, please check with your hosting company, but it is often called public_html or www.

7) Edit Your wp-config.php file

On your new hosting site, edit the file wp-config and adjust the configuration so your WordPress site points to your new database as created in point 2.

The things that will need to be altered are:

/** The name of the database for WordPress */

define(‘DB_NAME’, ‘new db name‘);

/** MySQL database username */
define(‘DB_USER’, ‘new db user‘);
/** MySQL database password */
define(‘DB_PASSWORD’, ‘new db password‘);
/** MySQL hostname */
define(‘DB_HOST’, ‘new db host‘);

Take A Deep Breathe

This is the point where you need to move your domain, this is where it can get a bit hairy, if you migration is not done properly, you site will go down  when you point to an incomplete WordPress migration.

Test Before Migrating

If you new hosting company supplies a temporary URL (Godaddy does for example.) add the following two lines to your wp-confog.php and set the URLs to be your temporary address.  This will enable you to test your config before migrating your domain name.

define(‘WP_SITEURL’, ‘http://example.com/wordpress’);
define(‘WP_HOME’, ‘http://example.com/wordpress’);

Remember to remove these once the test is done.,

9)Migrating Your Domain Name

Are you going to move your domain name to your new hosting, or just point it to the new hosting?  There are a few ways to migrate your domain

Changing The Name Servers (easiest)

Probably the easiest way to do the domain migration is to change the name servers on your old hosting account to the ones on

Unfortunately I cannot give detailed instructions on how to so this as every hosting company does it a little differently. But here is the process

  1. Get the new name servers from your new hosting company, the usually take the form ns1.newhosting.com and ns2.newhosting.com.
  2. Go to you old hosting and update the name server option
  3. Domain replication will take place NB there is sometimes a propagation delay of up to 24 hours before name servers are updated.

Updating name servers leaves your domain registration with the old hosting company and ONLY points to a new hosting location.  If you want to move you hosting and domain registration use the next process.

Move your domain to the new hosting company (more complex)

A more complex and time consuming way to migrate your domains is to move your domain registration.  Again the process is different for each hosting company, please see their documentation.

  1. Notify your new hosting company that you want to transfer a new domain into your account
  2. Ensure the domain is unlocked at your old hosting company (see their documentation)
  3. You will be supplied a series of migration codes enter these into the domain console as directed.
  4. The migration process is initiated and the domain is migrated into your new hosting account, and pointed to the files / database you have moved.

Domain transfers can take a number of days so I recommend a hybrid approach of moving the name servers then moving the registration.

This is a very common occurence and your hosting company(s)  will be able yo help you.

10) Test, Test and Test Again

Your site should now be live on your new hosting account, it is time to test.  Here are some of the things you should check

Check you have the correct number of posts pages, comments etc from the check points you took in the pre-migration test stage

  • Add a new test post
  • Upload an image  file
  • Test you can see images in your posts#
  • Test your sidebar is working

Points  To Watch

Sometimes your upload path will be hard-coded with a directory that is not available on your new hosting. If this is the case you will not be able to upload files and you may have issues displaying images.

To test if this is an issue navigate to settings -> miscellaneous and if you see an entry with a long path rather than wp-content/uploads you may have an issue, set it to the default wp-content/uploads.

Another common problem is with the .htaccess files, and your permalinks, if your home page works, but not your posts and pages (you get 404 errors) then regenerate your permalinks form settings -> permalinks

Wrap Up

Migrating hosting accounts is not the easiest things in the world take it slowly and do each point carefully and you should be able to migrate your hosting.

Leave a Reply

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