Moving one digital life, part III:
Moving WordPress to a new host

This tutorial will tell you how to move your wordpress blog from one web host to another. It assumes you have some basic knowledge of using an ftp application to upload and download files, and that your web hosts use phpMyAdmin for database management. It also assumes that you are somewhat familiar with using your WordPress admin pages.

This tutorial was based on my recent experiences. It’s compiled from information I found online, and help I got from other people, and my host. I can’t guarantee it will work for everyone, and by following it, you agree not to hold me responsible if something goes wrong. I strongly recommend reading through the entire tutorial before deciding to follow any of these steps.

Moving your WordPress (2.0+) blog can be fairly simply. I personally had a few hiccups in the process, but I’ll start with the easiest way of doing it, and then add what I had to do to get around some problems. There is also some great resources over at Podz’ WordPress Guides.

1. Download all of your files from your current host to your local hard drive (if you don’t already have copies). Include all of the WordPress files, and any files that you added to the site.

2. Download a copy of your WordPress database to your local drive. The easiest way to do this is to use the ‘backup’ plugin that comes with WordPress. Login to your WordPress admin page, and then go to ‘Manage’, and then to ‘Backup’. If you don’t see ‘Backup’ listed, then you need to activate the plugin, from the ‘Plugins’ tab. Next, select the ‘Download to your computer’ option, and click ‘Backup!’.

If your site is currently down, and you can’t get to your WordPress admin pages, then you can use phpMyAdmin to get a copy of your database.

3. You now have all of the files you need for your site. The next step is to start preparing / moving files to your new host. Log into phpMyAdmin on your new host, and create a new (empty) database. note: on some hosts you would actually create the database using a separate tool, and then administrate the database through phpMyAdmin. That’s how it is for my host, MediaTemple. Name the new database whatever you like.

4. Now that you have your new database setup, you need to import all of the data from your old databse. If your database is under 3-4MB, continue reading this step, and then skip step #5. If your database is larger than 3-4MB, go to step #5 now.

Different versions of phpMyAdmin look a little different from each other, but basically we want to find the import function. In some versions there is an ‘Import’ tab, in others the import function is listed under the ‘SQL’ tab. Either way, there will be a button to select a file for upload. You would use that button to upload the database file that you downloaded in step #2. If uploading was successful, move on to step #6. If uploading failed, read step #5.

5. My database was too big to use the method outlined in step #4, so I had to import the data using the unix command line. For the steps below, I’m using the ‘Terminal’ application in Mac OS X. You could do this from a PC too, but I’m not sure what tools you would use. A strong note of warning… The command line is very powerful! With great power comes great responsibility. You have the potential to screw things up, so you should only use the command line if you are comfortable with that risk.

In order to use the command line, you’ll need SSH access to your server. Not all hosts offer this, or it may be off by default. Check with your host.

In order to import the data via the command line, first you need to uncompress the database that you downloaded from you old host, so that you have the .sql file, instead of a gzip archive. Upload the .sql file to your new host, put it in the root directory to make it easier. I’ll be giving you some terminal commands below, anything within parentheses () should be filled in with your specific information, and remove the parentheses.

Log into your new hosting account through the Terminal:
ssh (domain name) -l (user name)

Type your password when prompted, and hit [Enter]

Type in:
mysql -u(your database user name) -p(database password) -D(name of the database you created in step#3) < (name of file you uploaded.sql)

If all goes well, that’s it… your data has now been imported into your new database. You can close the terminal. You can check to see if your data was imported into your new database by logging back into phpMyAdmin and viewing the database. note: if you have SSH access to both your old host, and your new host, then you can actually just import the data without downloading the database and then re-uploading it. I don’t know how to do that, so I’m not covering it here.

6. You’re almost done, just 2 steps left! Go to the site files that you downloaded from your old host, and open the file named wp-config.php. You’ll need to edit the information at the top of that file to reflect the new database name, user name, password, and possibly ‘DB_HOST’.

7. Upload all of the files to the proper directory on your new host.

That’s it! If all went well, you wordpress blog has successfully been moved from one host to another.

Unfortunately, in my case, there were a few more steps. After following the steps above, my site worked fine, but WordPress itself had a few bugs. I had to reinstall WordPress from scratch. I’m not going to go over that in as much detail, but I will give you the super-quick rundown version:

1. Move all the files on your new host into another folder on the server (to get them out of the way).
2. Create another blank database.
3. Install WordPress from scratch using their instructions. WordPress will populate your new database with empty fields.
4. Using phpMyAdmin, delete the new database fields that WordPress created in step #3. [ more info ]
5. Using the methods mentioned earlier, re-impoort your data into the new database.
6. Re-install whatever plugins you were using.
7. Move all non-Wordpress files back into your main directory (from step #1)

After all that, everything seems to be working again. Yay!

This post ballooned into a much longer post than I had anticipated, and after writing it I realized that so much can happen that would cause these instructions to change. So, please use this is it was intended… just to get you started with some basic information, or to fill in some gaps in information you already have. You may need to figure out some more things along the way. In addition to Podz’ WordPress Guides, I also recommend looking through the WordPress Codex, and the WordPress user discussions for finding more information.

4 thoughts on “Moving one digital life, part III:<br />Moving WordPress to a new host”

  1. I’ve done this several times, with a few extraneous steps. Your process is more concise and streamlined. Thanks.

    I’ve always installed WordPress and then overwritten the database with my old content. It worked pretty well. But I didn’t need to overwrite the database.

    A shorter process is much appreciated.

  2. Today, I moved my blog to a new host. I selected Bluehost. I wanted to drop you a note to let you know how much I appreciated your detailed article above. I was very nervous having never had to use PHPMyAdmin to reload a database.

    However, by following your suggestions, it came off without a hitch. I’d done my homework, had all the right information and data files at hand…so things went pretty close to perfect. Even the few hiccups were easily overcome.

    Thanks,
    John

Leave a Comment