Migrating Your WordPress Site with the Free WP Migrate DB Plugin

Moving a WordPress site, although a very common requirement, continues to put developers in a fix. The myriad of WordPress plugins and endless possibilities of WordPress implementations further complicate this process. Fortunately, plugins like WP Migrate DB, can do all the heavy lifting, making migrations smooth and easy.

In this article, I’ll walk you through the steps of migrating or moving a complex WordPress website from one server to another with the free and extremely reliable WP Migrate DB plugin by Delicious Brains. I’ll also briefly discuss some of the premium features of the WP Migrate DB Pro plugin family that allow integrating migrations in your regular development workflow.

My goal here is to help you make informed decisions and guide you through the nuances of WordPress migration. There are many aspects to consider when choosing the right migration plugin. Whether you choose to use WP Migrate DB or another plugin altogether (e.g. like our very own Shipper migration plugin), understanding how such plugins work will certainly make your decisions much easier.

Continue reading, or jump ahead using these links:

What Exactly Does WordPress Migration Entail?
Four Migration Scenarios
Migrating WordPress: the Prerequisites
My Migration Setup
Prepping Up Migration with the Two Important Details
Installation Directory of the WordPress Core
Table Prefixes

Step 1: Setting up WordPress on the Destination Server
Step 2: Exporting the Source Database with WP Migrate DB
Step 3: Copying the Necessary Files
Step 4: Importing the Database with phpMyAdmin
Final Migration Steps
Troubleshooting Issues
Features of the Premium Version

What Exactly Does WordPress Migration Entail?

WordPress is a content management system, which essentially means that all content and settings reside in a WordPress database. Themes, plugins, and media format and extend a WordPress site, and the database holds everything together. Moving files from one location to another is relatively easy; however, that’s not the case with the database. The URLs within the database are relative to its web server and directory structure. And so, moving the WordPress database also requires such entries to be replaced with those relative to the destination web server.

To add to this, WordPress and many plugins use serialized arrays, objects and JSON encoded data to store information in the database. Although a debated topic, data serialization is widely used as it helps in reducing the database entries, resulting in fewer calls to the database, thereby improving performance.

This, however, has an impact on WordPress portability, and one cannot simply replace URLs in serialized data. The data thus needs to be unserialized, replaced, and serialized again. With nested serialized data this process gets even more complicated. This is where plugins like WP Migrate DB make life really simple by handling all the grunt work.

Note: If you simply want to move WordPress from the default webroot location to a subdirectory on the same hosting server, have a look at Giving WordPress its Own Directory

Four Migration Scenarios

You may find yourself moving WordPress in one of the following scenarios:

A live server to another live server (both on the web)
A live server (on the web) to a local server (on your PC)
A local server to another local server
A local server (on your PC) to a live server (on the web)

In all these cases, the steps to migrate remain the same. All you need is to identify your source and destination WordPress sites.

Here’s an overview of how the migration would take place:

Migration overview with WP Migrate DB

Migrating WordPress: the Prerequisites

The bare minimum access that you will require to migrate your WordPress site with the free WP Migrate DB plugin is:

On the source WordPress end:
Admin access to the WordPress Dashboard
Access to themes, plugins, and uploads under the wp-content directory via FTP or your hosting server’s control panel software like cPanel, Plesk etc.

On the destination WordPress end:
Access to the destination hosting server via FTP and cPanel (or your control panel software) to install WordPress and copy necessary files
Access to phpMyAdmin or the database management tool that’s available for your hosting server

Note: If for some reason you do not have access to your hosting server’s control panel or the database management tool such as phpMyAdmin, you can still migrate your website only using the WordPress admin, but you will require the premium version of the plugin, WP Migrate DB Pro. I’ll discuss this a little later in the article.

My Migration Setup

I have a pretty customized WordPress setup on my local machine that I want to migrate to a live server. It uses the Genesis theme framework with a child theme, a lot of plugins, each with its own settings, customized widget areas for sidebars and the landing page, and a lot of media files.

Source WordPress installed on my local machine

Another important consideration is that I don’t want to redo any of the WordPress settings such as creating widgets, users, forms, galleries, media uploads, etc. after migration. The only thing I will redo is any advanced settings made in the .htaccess or wp-config.php files.

So, let’s get started.

Prepping Up for Migration with the Two Important Details

There are a few key things to keep in mind before starting the migration process:

Installation directory of the WordPress core
Table Prefixes

Installation Directory of the WordPress Core

You need to know where the source WordPress core is installed – in the default webroot location or in a subdirectory.

This is crucial as the destination WordPress needs to be set up in a similar manner. If the source WordPress is installed in a subdirectory, then the destination WordPress must be installed in a subdirectory as well.

Also, the name of the WordPress subdirectory should match on both ends. For example, if using the directory “sandbox” to install WordPress, both WordPress installations should use the same directory name i.e. “sandbox”.

As shown below, WordPress is installed in the photoreview_wp subdirectory of my local WAMP server, and not the default location i.e www or public_html.

WordPress installed in a subdirectory

Table Prefixes

Table Prefixes on both setups need to match too. The reason I’m bringing this up is that it’s best to set table prefixes at the time of installing your destination WordPress, and not later, as you’ll end up with unnecessary tables cluttering your database.

To find the table prefix used by your source WordPress, look at the $table_prefix value in your wp-config.php file.

In my installation, the source WordPress uses a table prefix of prwp_ and not the default wp_

$table_prefix value in wp-config.php

Last but not the least, make sure your source website is backed up.

If a subdirectory installation or wp-config.php sounds new to you, we have some great articles to get you up to speed:

When and How to Install WordPress in a Subdirectory
The WordPress wp-config File: A Comprehensive Guide

Step 1: Setting up WordPress on the Destination Server

With the prep done, the first thing you need to do is install WordPress on the destination server. In my example below, I have set up WordPress using the Softaculous auto-installer utility available in the cPanel of my destination hosting server. I modified the advanced options in order to control the subdirectory and table prefix settings.

Installing WordPress in a sub directory using the auto-installer

Other WordPress settings like site name, description, users etc. won’t matter at this point of time as these will be overwritten by those of the source WordPress at a later stage. The WordPress user created during the install process is needed only to log in to the Dashboard to set up the WP Migrate DB plugin.

Setting the table prefix with the auto-installer

Note: If you’re doing a manual WordPress installation via FTP, you can set the table prefix using the wp-config.php files or during the five-minute installation process. If you run with the defaults you’ll end up with the table prefix set to wp_

Step 2: Exporting the Source Database with WP Migrate DB

Migrating the database requires WP Migrate DB to be installed and activated on both the source and destination WordPress setups. This is because the plugin needs to know the drive path and URLs of the destination server in order to correctly substitute them in the source database.

Installing wp-migrate-db on both WordPress setups

Once done, head over to Tools->WP Migrate DB on both WordPress ends:

You then need to do the following:

On the destination WordPress end:
Check Export File and copy the entries that you see under the Find text boxes

On the source WordPress end:
Paste the copied entries to the empty Replace text boxes

Destination wordpress

Here, I’ve copied the URL and File Path entries from the destination WordPress at “thephotography.review” to the New URL and New File Path text boxes of the source WordPress on my local machine:

Source WordPress

You may also want to tweak the advanced options and uncheck Replace GUIDs if your source website was already live on the web. In my case, it’s a local setup so I’ve left it checked. I’ve also checked options to exclude transients and post revisions.

That’s it: on clicking Export, the source database SQL file is exported.

Exporting the WordPress database SQL

If the export times out, you can modify the Maximum Request Size option under the Settings tab, and try the export again.

Maximum Request Size option when request times out

Step 3: Copying the Necessary Files

The next step is to copy the themes, plugins and uploads directories located under wp-contents of the source WordPress to wp-contents of the destination WordPress via FTP or a method of your choice.

Copying Themes, Plugins and Uploads under wp-content

Make sure there are no errors during the copy process. Transferring data between servers may take a while depending on the number of files. Creating a zip archive through cPanel, and then migrating the folders via FTP could speed up the process.

For plugins, you may also decide to install them directly in the destination WordPress from within the Dashboard. If you choose to do so, I recommend that the plugin versions on both setups match.

Step 4: Importing the Database with phpMyAdmin

The next step requires you to import the database SQL generated in Step 2 to the WordPress database on the destination server.

To do this, you’ll need to access the databases on the destination server using phpMyAdmin or your database management tool.

Once in, make sure you select the correct WordPress database. This is the same database that was created while installing WordPress in Step 1. In my case, the database name specified for the destination WordPress was wp963. However, most servers will also add a prefix to this name e.g. someprefix_wp963

Setting the database name with the auto-installer

Identifying the correct database is crucial, as selecting a wrong database here will cause some other website to break on your server. If there are other WordPress setups on the destination, be sure to backup them as well.

To be certain, I recommend the following checklist:

Refer the DB_NAME value in the wp-config.php of the destination WordPress. It will contain the full database name including a prefix if any
Ensure that all the tables in the selected database have the same table_prefix as in the wp-config or the one specified in Step 1
Open the table_prefix_options table (prwp_options in my case) and verify that the siteurl and home option values match your destination WordPress

Verify the values in the wp-options table

Once you’re sure, head over to the import tab of the selected database. This is where the magic happens. Simply upload the compressed SQL (sql.gz) file that was generated in Step 2 with the format type set as SQL, and hit go.

Importing the database SQL through phpMyAdmin

Note: The import process will cause the database tables to be overwritten by the source and not merged with them.

When the import process succeeds, the destination WordPress will have all the settings, content, users etc. from the source WordPress. And just like that, the migration will be complete.

Final Migration Steps

If you head over to the destination WordPress, everything will be the same as the source. You’ll be able to log in using the same users as on the source, and any changes that you may have made on the destination WordPress will have been wiped clean.

Destination WordPress after migration

There’s one thing I would recommend, though: save the Permalinks again by going to Settings->Permalinks and simply clicking Save.

In my setup, I also changed the Site Address (URL) to exclude the subdirectory from appearing in the URL by following the steps here. Had I done this before the migration, it would have affected the URLs in Step 2.

Last but not the least, make sure you test everything. There are some great plugins that detect broken links. Here’s is a nice article to help you with that.

Troubleshooting Issues

There are many possibilities that may cause a migration to fail. Here are some ideas to help you troubleshoot in those rare cases:

If you face errors while uploading the SQL in phpMyAdmin, try generating the database SQL in Step 2 without the Compress file with gzip option.
If you’re unable to access the Dashboard you can try adding the following entries in your wp-config.php file:define( ‘WP_SITEURL’, ‘http://example.com/subdir_if_any’ );
define( ‘WP_HOME’, ‘http://example.com/subdir_if_any’ );These override options in the General Settings and the wp_options tables but don’t make any lasting changes to the database. If you were able to get back into your Dashboard with this, then you know that there was an issue with your URLs.
Missing media files would indicate errors during the copy process of the Uploads folder in step 3.
If you see a white screen ( also referred to as the White Screen of Death), check that the theme files were copied properly and that the correct theme is activated.

Features of the Premium Version

If you don’t want anything to do with phpMyAdmin and uploading and downloading of SQL files, you can simply migrate the entire database from within the WordPress Dashboard using the premium WP Migrate DB Pro plugin.

With the premium version and addons, the same migration process discussed in this post can be performed using just Step 1 and copying of the themes and plugins in Step 3.

Using the Push and Pull feature, one can simply push the entire database from a local to a live server or pull one from a live server to a local server with just a few clicks. You can also sync media files between two setups using the Media Files Addon. The other premium addons provide support for multi-sites and WordPress command line.

If you migrate websites regularly, WP Migrate DB Pro will certainly save you a lot of time.

Summing Up

That’s it.

The WP Migrate DB plugin family greatly simplifies the migration process but there are other options as well. We have some great articles to help you choose the migration plugin that’s right for you, including:

7 Top Premium and Freemium WordPress Backup Plugins Reviewed
5+ Awesome Plugins for Safely Moving WordPress
Migrate Your Website with Shipper WordPress Migration Plugin

Щелкните ниже, чтобы поставить оценку!
Всего: 0 В среднем: 0

Написать комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *