How To Move WordPress to a New Host
The process of moving WordPress to a new hosting company once seemed so daunting to me that I spent almost two years with a Web host I was very unhappy with. The site in question received a fair amount of traffic and was a consistent earner. I didn’t want to jeopardize those earnings by switching hosts and dealing with potential complications.
When I sold said site to a somewhat technically-challenged buyer, I had no choice but to dive right in. The simplicity of the move and lack of downtime amazed me, and I’ve since gone on to move the majority of my Web properties to a much faster, more reliable host.
Clean Up and Get The Files
To get things started, you’ll need to download your site’s files. I recommended first going through your admin panel and deactivating/deleting unnecessary plugins and themes, as this gets rid of garbage files you don’t want to bring with you. Such files add to the time it takes to download and upload your site. As you’ll find out, the process is already tedious enough.
Tip: You’ll need your hostname, FTP username and FTP password to connect. If you haven’t done this before, contact your Web host.
Navigate to the folder containing the WordPress installation you want to move. You’ll usually find your site files in the <public_html> directory. Click on the sub-folder in which your site resides, and then right-click the folder and select “Download.” If your site resides in the root directory (i.e. the primary hosted site), simply highlight all of the files in the root directory and download them to a folder on your computer. I prefer to set the target location as the desktop for easy access.
Be patient. Depending on the number of themes, plugins, photos and other files you have, this process could take some time.
Get the Database
Now that the site files are downloading, it’s time to turn your attention to the true heart of your WordPress site: the database. The database is perhaps the most important part of your site, because it contains all of your posts and custom data.
Access MySQL through your Web hosting control panel. Here you should see a list of your databases and a link to manage them through phpMyAdmin.
You should now be at the database-management screen, which looks like this:
Click on “Export,” and then check the selection boxes next to “SQL” and “Save as File.” Scroll down and click “Go” to export the SQL file. It should now automatically download to your computer.
Set Up a New Database and Import Data
In all likelihood, your site files are still downloading, so we’re going to move on to set up the database with your new Web host. Sign in to your new hosting control panel and open MySQL. You should see a link here to set up or create a new database.
Create a custom MySQL database username, and then set a password. Make sure both of these are uncommon and difficult to guess to protect your database against intruders. Once you’ve created the database, your host should assign a custom hostname. Make note of these values and do not lose them.
Tip: In addition to standard characters, use numbers and/or capitalization.
When the blank database is created, sign in to phpMyAdmin to manage it. Click on the “Import” link, and then click on “Choose File.” Select the database SQL file you exported from the previous database. Click on “Go” to import your data into the new database.
Change the wp-config.php
By the time you’ve finished this, your site files should be finished downloading.
Open the folder you’ve downloaded containing your site’s files. In the root directory, you’ll see a file named <wp-config.php>.
Open this file using a text/PHP editor such as NotePad++, TextPad or NotePad2. Do not use a word-processing program.
Scroll down to line 42. Here you’ll see the field containing your MySQL database hostname, username and password. Each of the values will be stored between single quotation marks.
Replace the present values with the custom values you previously assigned when you created your new database. Leave the single quotation marks in place and save the changes to the wp-config.php file. The WordPress installation will now be linked to your database when you upload the site files.
Upload the Files to the New Host
Now you’ll begin the process of uploading the files to your new hosting account, which is simply a reversal of downloading the files from your previous host. Access your server via FTP and select the downloaded folder containing the files. Set the target directory to the directory or folder you want your new site to reside in.
Tip: If your site will be hosted as the primary site, upload the contents of the folder, rather than the folder itself, to the <public_html> folder.
The transfer may be time consuming, just as the process of downloading the site’s files from the previous host was.
Tip: Verify the permission code for the wp-config.php file on your new server is set to 600 (some caching solutions might require different settings) to prevent unauthorized access. You can view and edit the file permission code by right-clicking on the file when accessing your site via FTP.
When the files are finished uploading, you should have a complete working copy of your site on the new server.
Point your Domain to the New Host
It’s important to remember, that your domain is still pointing to the original copy of the site on the old server.
You’ll now need to complete the process by changing the DNS (Domain Name Server) settings of your domain to point to the new host. Some hosts will also require further setup for your domain. This may result in a bit of downtime for your site while the changes propagate. For this reason, I recommend initiating the switch during a time your traffic is generally minimal.
Navigate through the copy of the site and verify the transfer went smoothly. Check links and post attachments to make sure everything is working correctly, and then browse through your admin panel to make sure it’s working.
Tip: The admin log-in name and password are the same as they were previously.
Once the transfer is complete, it’s safe to delete the files and database on your old server, as the domain permanently points to the files on the new server.