Migrating WordPress from one host to another can seem daunting, but unless you’re changing the domain name it’s actually fairly straight forwards. For this tutorial, I will assume you are NOT changing the domain name.

The Filesystem

There are 2 important parts to any WP installation, the database and the filesystem. In particular, the wp-content directory. In order to speed things up, my advice is to install the WP software as new (forcing an update to the latest version). Feel free to copy old system files if required, but it’s mostly just a waste of time and bandwidth.

Instead the easiest solution is to FTP into your website and download a copy of the wp-content directory, this lists your themes, plugins and uploads. FileZilla is credited as one of the most popular cross platform clients. You should be able to get the connection details from your host or hosting control panel. Simply connect, navigate to the public_html or /var/www/html directory – basically wherever the root of the application is and then download wp-content. This can take a short while so it’s advised to proceed while this step is completing.

The Database

The WP database is serialised, so copying it from one system to another when the domain name changes will cause a few compatibility issues. Because we are NOT doing this, we can ignore this limitation. phpMyAdmin is the most commonly installed database administration software for hosted WordPress solutions, if you don’t have access to this software contact your host on what you can use to export your database.

Once you have loaded phpMyAdmin in your browser and select the database you wish to export. Once the database has been loaded, select the Export tab. You should export in sql format with “Add DROP TABLE” selected. Hit go, and a few moments later you’ll have a complete SQL file with everything you need to replicate the structure and content.

In Reverse

Now we have a “copy” of our site we can start putting it back together on our new server. This is super simple. First, let’s upload our SQL file with FTP so we have access to it, anywhere is fine outside of the directory root. /var/www/migration is where I would go. Now, let’s put our wp-content back in place on our new site. Again, this might take a while so do it while you continue.

For the database import I’m going to assume you’ve already created it and setup permissions as in this post.

The next stage is to connect to our server via ssh.

mysql -u wp -p wp < /var/www/migration/export.sql

Make sure you check the location and file name of the sql file. The first wp is the database user, and the second is the database name. If it worked, there’ll be no output. But that’s okay because you’d get errors otherwise.

The final stage to get this working is to reconfigure our wp-config.php file if required.

sudo nano /var/www/html/wp-content.php

You’re going to want to check the DB_NAME, DB_USER and DB_PASSWORD line up. save this file and your site should be working.

There are currently no comments.