Moving a WordPress website

Importing/ Exporting a WordPress website

Although initially designed for personal bloggers to manage their posts and photos, WordPress has become such a popular content management system that developers are using it more and more to build professional business websites. So we find ourselves often building a WordPress site on a local test server, then needing to migrate it to a client’s own server (and vice versa). It’s not an intuitive process to migrate WordPress sites, so here are three possible ways to migrate a WordPress website from one server to another.


WordPress Import / Export

WordPress has it’s own import/export function designed to transfer your blog from one location to another, designed originally for bloggers who changed hosts or maybe had to change their URL.

  1. Export the database

In your WordPress dashboard, select Tools -> Export. This creates an XML file containing all the content of your site. Save this on your computer somewhere.

  1. Import the database on your new server

Assuming you’ve already installed WordPress on your new server, select Tools -> Import. You choose the XML file you just created, and also tick the ‘download and import files’ box so WordPress will copy all the uploads, images etc to the new location.

  1. Copy your plugins

 This needs to be done manually – that is, either copy your wp-content/plugins folder via your server’s CPanel or reinstall the same plugins in the new WordPress dashboard.

  1. Fix the Settings on your new site

This also needs to be done manually – that is, go through all the settings in the Settings area and make sure they are the same. All of them…


WordPress Migration plugins

There are a few plugins for WordPress that make this migration simple and easy – though, as with many plugins, the simpler your site is, the simpler they work for you. Some examples:

WP Migrate DB

Does a database dump and updates the URls much like the PhpMyAdmin solution below. Download it from WordPress.org

WP- Duplicator

Migrates a site from one location to another in 3 easy steps- download it here…

WordPress Move

Transfer, migrate and backup your site- download it here…

Please keep in mind moving a WordPress website is not easy and plugin solutions will help with much of the lifting but rarely get everything 100% right. Things such as author profiles and settings seem to go west using most plug-ins, categories go upside down and often slideshows disappear completely.


mySQL database transfer

Many advanced users prefer to migrate WordPress sites by directly moving the database files in their CPanel and amending the database to use the new URL. It’s a payoff between less manual amendments in WordPress itself and the risk of breaking the database by meddling in it directly.

  1. FTP all the WordPress files to the new location

Download all the files from your old WordPress site to your computer, then upload them to the new site. You have also made a backup on your computer during this process – it’s a good idea to make another backup somewhere else, too.

  1. Export the database using PhpMyAdmin

Under Databases in your Cpanel (on your old install), log in to PhpMyAdmin. In the top-left Database drop-down menu, select the database for your WordPress install. It will list all the tables in the right panel. Then click Export.

Select all the tables at the top-left of the new screen (click Select All), then Save As File at the bottom of the screen.

  1. Create a new WordPress database on your new server

We’re going to make a new database on the new server and then copy the exported database into the new one. On your new server, under Databases in your CPanel, log in to PhpMyAdmin. If you don’t see a field to create a new database, click the home symbol on the top-left. The Create new database field will appear in the main panel. Enter the name of the new database and click Create.

  1. Create a new PhpMyAdmin user

We need to create a new user as an administrator for the new database. Click the Privileges tab on the top-right. Click Add as new User under the User Overview. On the next page, choose a username and password, and choose localhost in the Host field. Below the Global privileges section, click the Go button.

On the next page, select the new database in the box marked Add privileges on the following database. Then you click all the items under Data and Structure in the Edit Privileges screen that it takes you to – then click Go.

  1. Import your old database into the new one

Staying in PhpMyAdmin on your new server, select your new database in the top-left box and click the Import tab at the top of the screen. Click Choose File under File to Import and find the database you exported from the old server. Then click Go.

  1. Change the URL (if you need to)

If you have a new URL you’ll need to replace it in the database. If you have the same URL you can skip this step.

We’re going to run an automatic SQL query to replace all instances of the old URl. Click the SQL tab, then enter the following code under Run SQL query/queries on database:

  • UPDATE wp_posts SET guid = replace(guid, ‘http://www.old-domain.com’,'http://www.new-domain.com’);
  • UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.old-domain.com’, ‘http://www.new-domain.com’);
  • UPDATE wp_postmeta SET meta_value = replace(meta_value, ‘http://www.old-domain.com’, ‘http://www.new-domain.com’);
  • UPDATE wp_options SET option_value = replace(option_value, ‘http://www.old-domain.com’, ‘http://www.new-domain.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;

Then click Go.

  1. Update the wp-config.php file

The wp-config.php file tells WordPress where to look for the databases it needs. You’ll need the database name, User and password that you used to create the new database. Find the wp-config.php file in your Cpanel. Edit the file with the CPanel text editor and replace the following:

<?php

/** The name of your new WordPress database */

define(‘DB_NAME’, ‘new-site’);

/** MySQL database username */

define(‘DB_USER’, ‘yourusernamehere’);

/** MySQL database password */

define(‘DB_PASSWORD’, ‘yourpasswordhere’);

The next settings should not change but check them:

/** MySQL hostname */

define(‘DB_HOST’, ‘localhost’);

/** Database Charset to use in creating database tables. */

define(‘DB_CHARSET’, ‘utf8′);

/** The Database Collate type. Don’t change this if in doubt. */

define(‘DB_COLLATE’, ”);

The Wrap-Up

So you can see that there are a number of ways to move your site from the development stage to the live server – or to move your site in case you need to change your server or domain name. As WordPress develops from its blog roots into a full content management system, these tools will become ever more important and robust to make moving your WordPress site as easy as possible.

wordpress-logo

Other Articles you might be interested in

wordpress-logo

Moving a WordPress website

Importing/ Exporting a WordPress website Although initially designed for personal bloggers to manage their posts and photos, WordPress has become … [Read More...]

HTML5_Logo

HTML5 Explained

What is HTML5? HTML is the code used to program what you see on the screen when you view a website in a browser. HTML5 is the latest incarnation of … [Read More...]

About Robin Jennings

I'm a creative web designer that specialises in designing and marketing websites for small business owners, community groups and creative types. I'm based in regional Victoria but work with clients Australia-Wide as well as a healthy sprinkling of overseas clients through my Web Design Agency: Explainafide

Trackbacks

  1. [...] Assuming you've already installed WordPress on your new server, select Tools -> Import. You choose the XML file you just created, and also tick the 'download and import files' box so WordPress will copy all the uploads, images etc to the new … WordPress hack 2013 Moving a WordPress website – Rack Servers Web Hosting Blog WordPress hack 2013 Assuming you've already installed WordPress on your new server, select Tools -> Import. You choose the XML file you just created, and also tick the 'download and import files' box so WordPress will copy all the uploads, images etc to the new .. WordPress hack 2013 Moving a WordPress website – Rack Servers Web Hosting Blog [...]

Speak Your Mind

*