Get fresh WordPress Content delivered in your inbox with warpspeed!

learn wordpress wplift wordpress rocket

Migrating your WordPress website from one host to another is often a daunting task. You don’t want to mess up anything. However, you still have to migrate for one reason or another. Surely, you can pay a professional freelancer to do the job but where’s the fun in that? Fear of downtime and data loss are two major factors that discourage people to not carry out the migration themselves.

It can be a complicated process, especially if it is your first migration. There are lots of moving parts to take care of, and if you don’t take necessary precautions, you may seriously end up causing data loss.

In this post, you will learn about how to properly migrate WordPress from one host to another.

Components of a Proper Migration

In a proper WordPress migration, there are several components to maintain. That’s why you need to have a well-planned, step-by-step process to carry out the migration. Here is what a proper WordPress migration looks like:

  • A backup is made as an insurance
  • All posts, pages, post types and taxonomies are migrated
  • All media files are properly transferred
  • No theme settings are lost
  • There are no broken links

If one of these components are not properly done, the migration will no longer be “proper.” The breaking of links results in potentially hurting website SEO, which you can’t afford that. Neither can you afford the loss of any theme settings, posts or media files. All of them when properly transferred are to the another host is what constitute a proper migration.

How to Migrate One Host to Another?

Step#1: Backup Your Files

backup-files

First off, you need to make a backup of entire WordPress site i.e. database and files. In this step, you will backup the files.

What Files to Download?

You need to backup the wp-content directory, which will be used during the migration:

  • Theme files: Without these files, the migrated site will not have same design
  • Uploads directory: It contains all the media files

Don’t proceed unless you have downloaded the said files to a secure location. It is extremely important that you take first two steps to avoid data loss. So, just backup the wp-content directory.

How to Take Files Backup?

  • Go to cPanel > File Manager
  • Browse to the root folder of your existing installation
  • Zip the wp-content directory
  • Download the zipped the wp-content directory

Zipping is optional, but it is easier to download and upload zipped files. All you need backup the files on your site is to backup the wp-content directory.

wordpress cpanel

Step#2: Backup the Database

A WordPress Database contains your posts, pages, theme settings, etc. It serves as insurance in case things go south. Plus, the database backup will be utilized during the migration. So it’s a must. Follow the instructions on your old host:

  • Open PhpMyAdmin and click your site’s database from the left sidebar
  • Go to Export tab, select Quick and click Go button
  • A file will be downloaded to your computer. Keep it safe!

phpmyadmin wordpress

The file you download constitutes your site database. You will need it to transfer the site data on the other host.

If you have multiple websites, you can go to cPanel > Backups and take a complete backup which will contain everything, files, database and all. But that’s a bit out there for this article, and we are only discussing single WP site backups here.

Make sure that you have deactivated all the plugins before taking the backup of SQL. We will reactivate them after migration.

Step#3: Upload the WP Installation Files

If you have properly taken backups, great! So far, you have not directed your domain name to the new host. So safe to say, you have ZERO downtime. Once database, uploads directory and everything is properly transferred to the new host, only then should you direct the domain name to the new host.

At this point, you will actually start the migration process. In this step, you will download and upload WordPress core files to the new host.

  • Download the ZIP file from WordPress.org.
  • Extract the package, upload its contents to the new host

You have the installation files. However, a database connection is yet to be made on these files. Let’s go ahead and install the WordPress CMS but first we need to migrate the files and our database.

We will install a new WordPress and then will replace the content files as well as the database. To avoid any issues, I recommend that you install the new WP with same credentials, same database name, user and same prefix as you have in your current host’s wp-config.php file.

Step#4: Upload The Files

Now you have a new WP installed on your new server. Let’s put back the files. In this step, you will upload the files you downloaded in the first step. Follow these instructions:

  • Go to your new server’s File Manager
  • Delete the new server’s wp-content directory
  • Upload and extract your old server’s wp-content directory

Now we have the files migrated.

Step#5: Create & Import Database

Now that all the necessary files from old installation have been transferred to the new host, it’s time to migrate the database. Perform following actions on the new host.

Database Creation

wordpress-database-creation

  • Open your cPanel account, go to MySQL Database Wizard
  • This module will help you create
    • a database
    • an SQL user (use a secure password)
    • and a connection between the two
  • During the wizard, take note of the database name, SQL user, and its password.

Make sure all the details you enter here to match the details of your old host’s wp-config.php file.

Importing the Database

wordpress database import

Currently, the database you created has no tables and hence, no data or anything. You need to upload the database backup you made in the first step. Follow the instructions:

  • Go to cPanel > PhpMyAdmin > Import tab
  • From File to Import section, click Choose File button
  • A popup window will open, use it to locate the database backup and upload it

The database contains the most important data of your website. It is almost the backbone of your site.

Step#6: Edit wp-config.php

wp-database-files

Now that you have migrated uploads directory, theme files, and database, it is time to make the database connection. For that, you will need to update wp-config.php file with the database details. As soon as the database connection is made, the migration will be officially done. You just need to direct your domain name to the new host by updating its nameservers. Which you can ask the domain registrar to do for you.

All good hosts allow you to preview the new site before changing the DNS of your domain.

To edit wp-config.php follow this step, follow these instructions:

  • Go to cPanel > File Manager
  • Browse to the WordPress files on your new host
  • Look for a file named wp-config-sample.php and rename it to wp-config.php
  • Once that’s done, open it and locate the following lines:
    • define(‘DB_NAME’, ‘db_name’);
    • define(‘DB_USER’, ‘db_user’);
    • define(‘DB_PASSWORD’, ‘db_pass’);
  • The database details you noted the last step should be entered here. Replace db_name, db_user and db_pass with database name, user name, and password respectively.
  • Save wp-config.php!

Is It Done?

So, you have installed a new WordPress site on your new host, replaced the wp-content directory and imported the old server’s database, and redirected your domain to the new host.

Well, you may now try visiting your website. It typically takes nameservers 24-48 hours to be propagated, so it may not yet be directed. In that case, you will see nothing. However, once the domain name is propagated with the new host. The website should be exactly like it was before i.e., same posts, pages, users, theme settings, etc. Congratulations, you have migrated your first WordPress site ever!

P.S. You can use a few tools to verify the health of DNS.

Conclusion

Migrations are difficult and can be unpredictable sometimes. But if you are completely familiar with the site structure, it should not be an intimidating task. To take precautions by creating a full-fledged backup is the best thing you can do.

What do you think about this WordPress host-to-host migration guide? Do you have any comments or tips for readers? Leave them in the comments.

Finally, you can catch all of my articles on my profile page, and you can follow me or reach out at Twitter @MrAhmadAwais; where I write about development workflows in the context of WordPress.

As usual, don’t hesitate to leave any questions or comments below, and I’ll aim to respond to each of them.

Published:

Last updated on:

I am a senior Full Stack WordPress Developer, WP Core Contributor, Front-end Fanatic and an accidental writer. I love to write, talk, build, and share everything about WordPress. You can reach out to me at Twitter @MrAhmadAwais.

Join 40,000 WordPress Astronauts
AND GET OUR LATEST CONTENT IN YOUR INBOX WITH WARPSPEED

We will never spam you.
close-link
siteground coupon
Get 60% Off the No. 1 WordPress Hosting!