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.
- 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.
- 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.
- 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.
- 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
Migrates a site from one location to another in 3 easy steps- download it here…
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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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’;
- Replace http://www.old-domain.com with your old domain name
- Replace http://www.new-domain.com with your new domain name
Then click Go.
- 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:
/** The name of your new WordPress database */
/** MySQL database username */
/** MySQL database password */
The next settings should not change but check them:
/** MySQL hostname */
/** Database Charset to use in creating database tables. */
/** The Database Collate type. Don’t change this if in doubt. */
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.