Moving a WordPress Site to a New Domain Name

By November 22, 2013Blog

This guide will help you with backing up a WordPress site, and moving it to new hosting while changing the domain name as well. While there are a great number of ways to go about this process, this is our general approach. The process of moving a site from a staging server to a new live server is fairly simple, but includes a number of steps which are:

1. Exporting the database from the staging site location using phpMyAdmin

The process of exporting a database using phpMyAdmin is fairly easy. You’ll need to log into phpMyAdmin first. In most cases, you can access this tool from your web hosting administration screen. To actually back up your database, you’ll want to follow the instructions provided here: http://codex.wordpress.org/Backing_Up_Your_Database#Using_phpMyAdmin.

2. Downloading all of the site files via FTP from the staging site location

This is as simple as logging into the site via FTP and downloading all of the site files to your local computer. It can take awhile, even several hours depending on how many images you have uploaded to your site, and your connection speed.

3. Do a find/replace on database to update URL of site

Since the web site address is changing, you’ll need to do a find/replace on the database to change all references to the old domain name. The simplest method is to open up the database backup file in a text editor (such as Notepad, TextMate, Dreamweaver, or similar tool). Once the file is open, you’ll want to do a find & replace to change the old site URL to the new site URL. For example, if your previous domain name is http://www.example.com and your new one is http://www.domain.com you’ll change all instances of the old URL to the new URL. Once done, save the file, which you will later upload.

While it doesn’t work in every instance, this method is the easiest and fastest way to change the URL. If you encounter problems, you may need to use a database tool to update the URL, but in almost all cases this method works.

4. Delete the files on the new location (after backing up via FTP)

Since a WordPress installation exists at the new location, you’ll want to just move all of the site files out of that folder on the server. You can create a ‘backup’ folder and move the site files into it, or download a copy as a backup.

5. Import new database using phpMyAdmin

Create a new MySQL database on the server (an empty one) and create a username and password for it. Then, import your WordPress database file (the one you updated) into that empty database. For most cases, you can create a database directly on the web hosting administrative panel.

Then, to import the database simply log in to phpMyAdmin and start the import process. Follow the instructions under ‘restore process’ here: http://codex.wordpress.org/Restoring_Your_Database_From_Backup.

If your WordPress backup is so large that you receive errors, you can split it up into separate files and import each one separately. In the past, I have had cases where a database file was 50 MB or more, and had to be split into a dozen files (each server has different limits on the maximum file size you can upload).

Tools and comments are available to split the database backup file into separate files. One excellent top is called SQL Dump Splitter, and is available from: http://www.rusiczki.net/2007/01/24/sql-dump-file-splitter/

sqldumpsplitter2

6. Update wp-config.php to have new database username, password, and database name

WordPress uses wp-config.php (in the root folder) to identify which database to connect to. Update this file to have the database name, database username, and password that you created.

7. Upload site files to server via FTP

Upload all of the site files to the server. Once everything is uploaded, the site should magically load.

8. Configure Widgets, Permissions, Permalinks, Settings

Some things won’t transfer automatically, and those are usually the Widgets inside WordPress. So, simply go into WordPress, click on Appearance, then choose Widgets. You’ll also need to set up your permissions and permalinks, as well as check the settings in WordPress.

It should be noted that there are a multitude of backup and move tools for WordPress, and most are available as free Plugins. We’ve had success with these, although they’ll often not work correctly, especially when moving from one server to another. Your mileage may vary.

Join the discussion 2 Comments

  • Ryan says:

    Thank you very much for this blog post! I searched around for hours trying to figure out how to move my WordPress site to a new domain but only found bits and pieces on how to do it. I followed your steps and had no issues at all moving my site.

Leave a Reply