How to migrate your WordPress Database to a new host?


If you are having problem with hosting and want to change your hosting with WordPress theme site, then follow this main steps to move your WordPress Database to a new host.

  1. Create a backup

Before any major changes, it is always wise to create a backup file just in case things do not go according to plan and you have to roll back. There are a number of options for backup: you can use Sequel Pro, the Adminer plugin in WordPress or through phpMyAdmin on the cPanel of the server.

By default, your backup file saves as .sql, but it is better to save it as a compressed file format of your choice. Most hosts allow uploads no bigger than 2MB, hence by compression, you will stay under the limit.

migrate your WordPress Database to a new host

  1. Create a backup of wp-content directory

You can do this in two ways: you can FTP onto the server and then drag a wp-contentcopy file into your computer. For those who are more comfortable with using the command prompt and have access to SSH, they can try the easier command below that creates a tarball, which is easier than moving many small files:

tar -pvczf wp-content.tar.gz wp-content/

  1. Upload database to new server

You can do that using the Adminer plugin for this where you have already installed WordPress on the new host. If it is not, use phpMyAdmin on your new host. Where the server you are moving to runs WordPress, the better idea would be to create new databases and then upload your tables onto it. By doing this, should anything go awry you still have the option of rolling back to your old site.


Where your options are limited to a single database, you can alter the table prefix-and where you encounter problems that you are unable to address, contact remote DBA services at

  1. Sync searchreplacedb2.php

This file should go wherever your wp-config.php file is, usually at the top level of the server. The file will find every location that used the former domain and replace it with your new domain. This method provides an advantage over the database method in that it also alters serialized arrays. There are more resources on this online.

If you have a security concern, you can localize this process to the development server only such that the file will never reach or apply to the relevant production server. Where the server includes the WP CLI plugin, a wp search-replacefunction line is applicable in place of this command.

  1. Load the search/replace tool

This is available on and what it does is automatically fill up the database found in wp-config.php. Next, select your application tables and then type in your new and old domain on the find/replace tab that opens. Do not add the trailing slash at the end of the domain. Carry out the find/replace function and then remove the file from the server.

  1. Copy of WordPress

In the case of a newly created website, you should upload a WordPress copy in addition to the bespoke wp-content directory. This is not necessary where there already is a live WordPress website.

Final word

These are just the first few steps involved in the upload of the database from an old server to a new host. After these, you have to implement a few more confirmatory steps, including changing the table prefix and troubleshooting steps.