How to move your WordPress blog to a new host

Wordpress icon - blue, small

by bledsoe on June 26, 2009

A few days ago I had the opportunity to move a WordPress site from one hosting company (1and1) to another (HostGator).  You can find a number of "here's how I did it" descriptions of this process online, most of which differ from each other in small ways.  I found this thread in the wordpress.org support forums to be helpful (particularly the post by rapidtronics about halfway down), but my experience was slightly different so I wanted to post it here in case it might be useful for others.

  1. Back up both your site's database and files. You'll probably use something like phpMyAdmin to back up your database (as described here); the database backup file will be a collection of SQL commands which will be used to populate your new database.  To back up your site's files, just use an FTP client to download all your site files to your PC.
  2. Set up the website space on your new host. This may involve creating an "add-on" domain in the main domain space of your new host.   Take note of the pathname to your new site's webspace.
  3. Create a MySQL database on your new host, and create a database user that has all access permissions.  Take note of the name of the new database, the new database user and password, and the hostname.
  4. Update your wp-config.php file. In a text editor, open up your wp-config.php file (from the site files you just downloaded from your old host) and change the entries for the database name, the database user and password, and the hostname, to reflect the newly created database on your new host.  You can now upload all of your site files (including the now-updated wp-config.php file) to your new webspace.
  5. Update the pathname to your webspace in your database. In a text editor, open up your database backup file (the one with all the SQL commands), and do a global search and replace.  You need to change all the instances of the pathname of your old webspace to the pathname of your new webspace.  In my case, the old (1and1) pathname was something like /homepages/2/d3758674/htdocs/mydomain and the new (HostGator) pathname was something like /home/bledsoe/public_html/mydomain.com.  If you skip this step, your new database on your new host will be trying to access files and directories on your old host (and won't be able to).  You can now import this SQL file to your new database, probably using phpMyAdmin, as described here or here.
  6. Change the DNS entries for your domain name. Assuming your old host is still the domain registrar for your domain name, go to the admin panel for your old host, and change the DNS entries for your domain so that they point to the domain servers at your new host.

Special note regarding email addresses associated with the transferred domain: Did you know that when you change the DNS entries for a domain, the MX records (that control where associated emails are sent) get changed automatically to point to the new domain?  If you have one or more email addresses associated with the domain whose webspace you're moving to a new host (e.g., name@mydomain.com), be sure you know where your MX records are pointing so your emails end up at the right place.

Previous post:

Next post: