How to Migrate a WordPress Site

These instructions are for moving a WordPress installation from one server or hosting company to another, but they can also be easily applied to moving WordPress from one domain name to another on the same server (for that skip anything relating to the database). Moving WordPress has three basic steps: 1- Copy the old site, 2- Upload the site to the new server, and 3- Configure WordPress for the new server. This tutorial will provide information on completing these steps for a hosting account in a cPanel platform like the one used by Bluehost, HostMonster, JustHost, FastDomain, and others. The steps will be similar for other hosting providers.

Step 1- Copy the Old Site

This is where we get everything for WordPress from the old server so we can put it on the new server. There are two parts to this step: first, copying the files, and second, copying the database.

Part 1- Copying the Files

To copy the files, log in to your cPanel and open the File Manager tool in the Files section. On the pop-up window select the Document Root option and choose the domain for the site you are moving from the drop-down menu. At the bottom click the box for Show Hidden Files and click the Go button. Note: If the File Manager doesn’t give you this pop-up, but just opens, you will need to select and open the folder where you have WordPress installed from the directory tree on the left. When the page loads it will be displaying your WordPress files. In the small row of icons click Select All. Everything will highlight in blue. Then from the larger row click Compress. On the pop-up window select the zip archive type and enter a name in the text box at the bottom. Then click Compress. When the compression results show close the pop-up and click Reload on the small row of icons. You will then be able to see the .zip file listed below. Right-click the file and select download to copy the WordPress installation to your computer.

Part 2- Copying the Database

We also need to know what database WordPress is using so we can get a copy of that. To find out, look for the wp-config.php file in the listing here in the file manager. Right-click and select Code Edit, then click Edit on the pop-up. The line that defines the database will look something like this:

define(‘DB_NAME’, ‘username_wrd4’);

In this example the name of the database is username_wrd4. Now we know what database to copy.

To copy the database go back to the cPanel and select PHPMyAdmin from the databases section. This tool will have you log in again, and the password is normally the same as your cPanel password. This tool will list your databases in the grey column on the left. Click the database that matches what was listed in your wp-config.php file (username_wrd4 in our example). Then at the top click the Export tab. When the page loads click Go, and PHPMyAdmin will download the database as a .sql file to your computer.

Step 2- Upload the Site to the New Server

In this step we will upload and extract the .zip file we made to the new server, create a blank database, and upload our .sql file to the new database.

Part 1- Uploading the Files

In the account on the new server you will want to open up the File Manager to the Document Root of the site we are moving WordPress to. Once open, select the Upload icon from the larger row of icons. In the tab that opens select the .zip file to be uploaded. The bottom right corner of the screen will display a progress bar. When completed you can go back to the File Manager by clicking the Go Back link at the bottom. You will then see your .zip file listed. Right-click on it and select Extract, then click Extract on the pop-up. Leave the File Manager open as we will need to do more here later. Note: if the .zip file is too big the File Manager won’t be able to upload it. If that’s the case with your .zip file you would need to use FTP to upload it instead.Most cPanels will include the Unlimited FPT tool in the Files section that you can use for this. Then you would use the File Manager to extract the files as described earlier.

Part 2- Creating a New Database

In the cPanel of your new account go to the Databases section and click the icon for MySQL Database Wizard. The first page of this tool will ask you for a database name. It will begin with your user name and the “_” character, then have a text box for you to fill in. You can name this whatever you would like. For our example, we’ll say the cPanel user name is newuser1_ and we entered wp in the textbox, so our database name would be newuser1_wp.

The next page asks for a user name and a password. Again you can do whatever you would like with these, and again the user name will automatically begin with newuser1_, like the database name did. For our example we’ll say we set this to newuser1_admin, with a password of “Password!”.

The last page will ask you to assign permissions for the user on the database. Select All Permissions and click the Assign button. You’ve now finished setting up the new database.

Part 3- Importing Your .sql File to the New Database

With the database created we can now import to it. In the cPanel go back to the databases section and open PHPMyAdmin. Select your new database from the grey column and click the Import tab at the top. Select your .sql file from your computer and click Go (no need to change any settings here). Your database will now contain all the content of the old one. From here, click the “browse button to look at the database. You’ll need to take note of the database prefix. Your tables will be named something like “wp_options”, where “wp_” is the table prefix. You’ll need to know what this is later.

Part 4- Update Your Domain Name in the Database (ONLY if you are changing your domain name as part of the move)

If you are changing your domain name as part of this move to a new server then we will need to make a couple of changes to the database while we are in PHPMyAdmin. The database defines the domain name WordPress operates on, so we need to give it the new domain. After we do that we can log in to the dashboard for any other changes we need to make. With the .sql file imported we can now click the Structure tab to view the contents of the database. Click the wp_options table on the list. When the options load you will see a line that says Site URL and has your old domain name listed. Click the edit link on that line, update the domain to the new name, and click Go at the bottom to save the change. This should then take you back to the options page.

We need to make this same change in one more place. At the top there will be a drop-down menu with Page Number next to it. Select page 2. On this page look for the option Home with the old domain name. Click Edit on that line and update this option also. With these changes to the database you will now be able to log in to the dashboard at the new domain name.

Step 3- Configuring WordPress for Your New Server

There’s a lot in this step, but hopefully you won’t need to do most of it. When WordPress is moved some things can break but usually won’t. I’m providing instructions for all scenarios here so you likely won’t need to do all of the parts of this step. Just keep going until your site is working properly on the new server.

Part 1- Connect WordPress to the New Database

Remember how I had you leave the File Manager open? Time to go back to it. You may need to click the Reload button in the small row of icons to get your extracted files to show if they aren’t already. From there you want to find wp-config.php and right-click, then select Code Edit. We need to update the file with the information for the new database. There will be three lines we will have to change, and a fourth that you might need to change as well. In the Code Editor these should all be in blue, with the rest in black:

define(‘DB_NAME’, ‘username_wrd4’);
define(‘DB_USER’, ‘username_wrd4’);
define(‘DB_PASSWORD’, ‘Pa$$w0rd123’);
define(‘DB_HOST’, ‘localhost’);

These need to be updated to match our new database settings that we entered in Part 2 of the last step. If your DB_HOST is set to anything other than ‘localhost’ change that also. The changes will make these lines look like this:

define(‘DB_NAME’, ‘newuser1_wp’);
define(‘DB_USER’, ‘newuser1_admin’);
define(‘DB_PASSWORD’, ‘Password1!’);
define(‘DB_HOST’, ‘localhost’);

Also, look for the row with the table prefix, and make sure it matches the prefix being used by your database tables:

$table_prefix = ‘wp_’;

WordPress can now access our new database.

Part 2- Updating Your Permalinks

If you find the links to your pages aren’t working (which is the most common problem after moving WordPress) don’t worry, it’s an easy fix. All you need to do is log in to your dashboard, go to the Permalinks option under Settings, and click Save Changes. This forces WordPress to update the links and almost always corrects the problem.

Part 3- Updating Your Image Links and Other Internal Links

If you changed your domain name as part of the move, odds are your images are broken. Even if they aren’t it’s a good idea to do this step if you changed your domain name. In your WordPress dashboard go to Plug-ins > Add New. Search for Velvet Blues Update URLs and install and activate the plug-in. This will add a new option under Settings called Update URLs. Under this option type in the old domain name and the new domain name in their respective boxes (you need to do the whole thing, starting with http://) and select all the check boxes below EXCEPT for the last one. Then click the Update button. This will go through your database and update your image links and other links from the old address to the new one.