Looking for Migrating WordPress entire site to a new server? The WordPress Codex explains the process (https://codex.wordpress.org/Moving WordPress). If you spend a little time preparing your own website, migrating is nothing to be concerned about. Let’s run through the steps required to move your WordPress website to a new host.
Step 1: Back Up Your Migrating WordPress Website Files
The first aspect of WordPress migration is to take back up of each and every element of your site.
Depending on the number of media uploads you have in your site, this could take some time. While this download is underway we can begin step two and make a copy of your database.
Step 2: Export The WordPress Database
Exporting your database is a simple process that only requires a few steps to complete. Login to the cPanel account of your web server and open the phpMyAdmin application. Select the database that contains your WordPress installation from the list on the left-hand sidebar and once selected click on the Export tab on the navigation menu.
The default settings of a Quick export and the SQL format for the export are sufficient for what we need. Click the Go button and the database export process will begin and a file will be downloaded to your local computer.
Step 3: Create The WordPress Database On Your New Host Server
Login to your new web host with the user details they have supplied you and connect to the cPanel software. For our guide, we will be using the MySQL Databases application.
The steps to create a database are simple:
- Open MySQL Database and create a new database
- Create a new MySQL user.
- Add the user account to the new database and grant it All Privileges.
Write down the database name, the new MySQL username, and its password. You will need them soon.
Step 4: Edit the wp-config.php File
Make a copy of this file and store it in another folder on your local computer. This is necessary for restoring the changes we are about to make should something go wrong later.
Open the original version of the file with your favorite text editor and make the following three changes:
1. Change The Database Name
Locate the following line:
Change ‘db_name’ to the name of the new database that you have created.
2. Change the Database Username
Below this you will find the line:
Change ‘user_name’ to the name of the new user that you have created.
3. Change The Database User Password
Finally, edit the third line:
Change ‘db_pass’ to the name of the new password that you have created for the new MYSQL.
Save wp-config.php and close the file.
Step 5: Import Your Database
Launch phpMyAdmin from the cPanel software on your new server and select your new database from the list on the left hands’ sidebar. Once it opens select the Import tab from the navigation menu.
In the section File to Import click the Choose File button and select the SQL file you exported previously.
Un-tick the Partial Import check box, make sure the format is set to SQL and then click the Go button. The database import will now begin.
You should receive a message informing you of the success of the import when it has finished.
Step 6: Upload The WordPress Files To Your New Host
Now that you have the new database prepared and you’ve reconfigured the wp-config.php file, it is time to begin uploading your website’s files.
Connect to your new web host using your FTP program and browse to the folder that your website is going to be held. If this is the primary, or only site being installed on this web server then uploading the files to the public_html folder is the usual directory.
With the remote directory selected you can upload your website files that should now include the updated version of wp-config.php. As with the earlier download, this process can take some time.
Step 7: Linking to New URL & Defining New Domain
One issue people always seem to have when moving their site is that they’ve added links to other posts on their site or inserted images directly by pointing to a URL on the server, causing these to break when moved over to a new domain.
If you want to quickly and easily search for any instances of your old domain name and replace with the new name, you can take a look at the Search Replace DB script on GitHub. This will allow you to change the URL easily. Just make sure you DELETE it when you are done (this is for security reasons).
Make sure you are running the search and replace on the new domain you are transferring the site to not the old one.
That’s it really. If you’ve gone through all steps your new website in the new server is ready and launched. If at any stage you go wrong, undo what you’ve done and start again with your backup.
There are also plugins which will help you move WordPress if you don’t want to do it all manually. I haven’t tested all of these, so I can’t vouch for their reliability or ease of use. If you do use one, do so with care.