Moving a WordPress Website to a New Host

Over the years a number of my websites have outgrown their hosting providers and needed to be moved to new servers, which can be a daunting task if you have an already established WordPress website with incoming traffic and links and other good things. However, if you have an organized plan of action to follow, it can be made a little less daunting.

First, make sure you have all your ducks in a row: Secure your new hosting account (I highly recommended HostGator WordPress hosting–use the coupon code wordpress for a special deal); make sure to make a back-up of your current website; check your logs and identify any slow traffic days and times (because that’s when you should begin your move), and, finally, take a deep breath.

The following will apply if you have an average-sized website, however, larger websites can use this walk-through as a guideline. OK, ready? Let’s begin.

1. Close commenting and trackbacks on all posts and pages. Taking this action means you’re less likely to lose any comments or trackbacks during the move and you can always go back after you’ve finished and open them both up again.

  1. Log into your phpMyAdmin account and select the desired database table
  2. Select SQL from the tabs
  3. In the Run SQL query box, type the following code: UPDATE wp_posts SET comment_status = 'closed' and ping_status = 'closed';
  4. Click on the Go button to run the query; all of your WordPress posts’ comment and pingback/trackback statuses should be closed

2. Delete all the spam comments from your database. It’s amazing how much spam can accumulate in the database if you aren’t diligent about keeping it clean. Luckily, deleting spam is as easy as logging into your WordPress admin and deleting it from your Akismet account. If you don’t have Akismet installed, you’ll need to follow the instructions below to delete it directly from the database.

  1. Log into your phpMyAdmin account and select the desired database table
  2. Select SQL from the tabs
  3. In the Run SQL query boxy, type the following code: DELETE FROM wp_comments WHERE comment_approved = 'spam';
  4. Click the Go button to run the query; all of the comments WordPress identified as spam will be deleted from the database.

3. Delete any other unnecessary data. It’s not uncommon for database-driven websites to fill up with cruft. Now’s the perfect opportunity to go in and clean it out. Log into your WordPress admin panel and delete any draft posts you don’t intend on finishing and comb through the comments which are awaiting moderation.

4. Optimize your database tables. This removes any stray data that’s lurking in your database which could cause errors or sluggishness down the road.

  1. Log into your phpMyAdmin account and select the desired database table
  2. Click on the Check All link and make sure a checkmark appears in the boxes next to each of the database rows
  3. From the drop down menu in the lower right of the database rows, select Optimize table from the list
  4. The process should start automatically and provide you with a report when it’s finished

5. Export your database. Now that you’ve removed the cruft and optimized your database, it’s time to export it. Assuming your new host will have phpMyAdmin installed, it’s a good idea to export the database as an SQL file.

  1. Log into your phpMyAdmin account and select the desired database table
  2. Click on the Export tab
  3. When the export page loads, double check that all the database tables are selected, the output format is .sql, and place a checkmark next to Save as File
  4. Click on the Go button and when prompted, select a name for your file

If your database is large, think 50MiB, then you’ll need to break up the export–you can export individual tables as opposed to all of them as the same time.

6. Download your files using FTP. Assuming you used the built-in website backup service, you’ll need to manually download your individual WordPress (and other) files using an FTP client such as Filezilla. If you manually backed up your website using FTP, then simply copy those files. (Make sure it’s a copy and not the actual backup files.)

7. Set up the database on your new hosting account. After you’ve created the database, import the SQL file that you exported from your previous hosting account.

  1. Log into your phpMyAdmin account and select your newly created MySQL database table
  2. Select Import from the tabs
  3. Choose to browse for the import file and select the SQL file you downloaded from your previous host
  4. Click on the Go button and you should receive a summary report when the process is completed

8. Update your wp-config.php file. Since you’ve created a brand new database, it’s important that you open the wp-config.php file with a plain text editor (or an editor specifically designed for editing PHP files) and update it with your new database information.

9. Upload your files to your new hosting account. Make sure that you keep all the file structures intact.

10. You’re ready to update your domain name’s DNS. Using the temporary URL provided by your new hosting provider, double check that the files are working as necessary. Due to WordPress’ design, you should be redirected to the main domain name–this is normal behavior which signifies that everything seems to be in order. Go ahead and switch your domain name’s DNS to the new host and give it some time to propagate throughout the web (about two weeks to be safe) before canceling your old hosting account.