How to Move Your WordPress Blog to a New Host

Teli Adlam —  May 18, 2007

You’ve outgrown your current web host and it’s time for a move, however, you have an already established blog. You have a lot of content and comments that you don’t want to lose with the change and you want as little down time as possible, what do you do?

Using this process, you will have a mirror image of your blog set up on your new server. That means you don’t need to re-install WordPress, you and your users’ login information will remain unchanged, and you don’t need to worry about updating any settings.

The following walk through applies to small to medium sized blogs, however, large blogs can still use it as a guide (with additional care, especially concerning the database export/import). Make sure you undertake the task on a slow traffic day to avoid any missed comments and minimize potential problems.

Prepare for the Move

Before you do anything at all, you want to back up your files (including your database). Once you’ve backed up your files, then you’ll want to FTP your current WordPress files to your computer.

With your back up safely tucked away, it’s safe to start playing around with your database a little bit. This is a lesson I learned the hard way with a number of moves, but you’ll want to delete all the spam records from your database before you export it for the move. (If you have Akismet installed, it’s a matter of deleting all the spam in your moderation queue.)

Deleting Spam Comments from the Databases

  1. Click SQL Tab After selecting your database, click on the SQL tab.
  2. Run Spam Query In the text area that appears, type the following SQL query and click on the ‘Go’ button:
    DELETE FROM wp_comments WHERE comment_approved='spam';

    If you changed your WordPress prefix, make sure you change wp_comments to match the change.

You can also use the above instructions to delete other unnecessary data from various tables that you don’t want to take with you. For instance, if you have the ShortStats plugin installed, you can empty the search tables by replacing the query with DELETE FROM wp_ss_search; and DELETE FROM wp_ss_stats.

(I shouldn’t have to tell you this, but please be careful when working with the database. A slight error and you could end up crippling your blog.)

After deleting the spam comments, you’re now free to optimize your database tables. This is fairly quick and easy using phpMyAdmin.

Optimize the Database Tables

Optimize DB Tables Return to your database admin page and click on the link to Check All database tables. From the drop down menu, select Optimize Table.

Export Your Database for Transfer

One thing to be aware of when planning your database export is the total size of the database. If you have an especially large blog (more than 40MiB), you may need to export each table individually so they can be imported to the new host with greater ease and fewer time out errors. You can find out how large your database is by looking at the Size column from the database admin page.

Prepare the New Host

You’ve downloaded your files from your current blog and exported your database, now it’s time that you move all of that information over to your new hosting account.

Log in to your new hosting account and create a new database. Once the database is created, then you’ll need to import the database you exported from your old hosting account. (Remember, if you had an especially large database, then you’ll need to import it table by table.)

Before FTPing the WordPress files to your new hosting account, make sure you update the wp-config.php file with the new host’s MySQL database information (i.e. the database name, user, and password you created with the new host). Using the information provided in your new host’s confirmation e-mail, FTP the WordPress files to the new server, making sure the folder structure remains unchanged.

Flip the Switch

After you’ve moved your database and files over to the new hosting account, it’s just about time to flip the switch. Double check that everything is in order (i.e. all the database tables are intact, the files are in their proper locations, and the wp-config.php file has been updated).

If everything is as it should be, update your DNS information from your domain registrar account and wait for it to propagate. During this period, it’s a good idea to keep your old hosting account alive until you’re sure the process is completed and all traffic is being directed to your new host. I like to have about a 1-2 week overlap, but it generally only takes a few days. Once the shift has taken place, it’s now alright to cancel your old hosting.

[tags]move wordpress to new host, moving wordpress, switching wordpress hosts[/tags]

Teli Adlam


13 responses to How to Move Your WordPress Blog to a New Host

  1. Nice detailed article, but you forgot to mention moving .htaccess file to new server. If a blog is using Permalinks, it required an .htaccess file.

    Like you mentioned above about large database. I remember I have written a post on how to move a large MySQL database easily using a tool.

  2. Hi Tech Duke,
    Thanks for stopping by and commenting.

    …you forgot to mention moving .htaccess file to new server.

    Not really. Maybe a bad assumption on my part, but when I stated to move the files to the new host, I assumed most people would know to move all files to the new host, including the .htaccess, robots.txt, and any other files.

    Thanks for pointing out your tutorial for moving large MySQL databases. Very nice write up and should prove helpful to those running a larger blog. 🙂

    ~ Teli

  3. Before changing any DNS records at least modify your hosts file (if on Windows) to verify the site actually works.

  4. Hi Ryan,
    Please excuse my question, but could you explain the purpose of modifying the Windows hosts file in this scenario?

    After moving dozens (if not hundreds) of WP blogs to new hosting accounts without a hitch, I’ve never needed to modify the Windows hosts and I’ve yet to encounter a problem.

    ~ Teli

  5. I just moved my blog to a new host and also a new domain, but all of the images on my posts still point to the old domain. Is there an easy fix for this or do I have to change everything manually?

  6. Teli,

    How would this differ if I’m moving from a host who uses a Windows environment to a Linux server? Does this require WordPress to be reinstalled? If not, then where do I get a properly configured .htaccess file because there isn’t one on the Windows installation.



  7. I ran into a problem while importing my old databases. I get an error that says: “Access denied for user ‘xxx’@’xxxx’ to database ‘xxxxxxx’ My old host’s sql panel won’t allow me to create a new user – is it possible to edit the database file to allow a new user?

  8. Accounting Teacher June 16, 2009 at 12:49 pm

    Thanks for this detailed tutorial on how to move wp blog to new host. I usually use free webhosting companies, and they vanish or terminate theire services quite often. This has been the big problem, as all my work is gone after this happens.

  9. Teli

    Updating the Hosts file is not necessary, but is a way to check on the setup on the new host right away, before updating the DNS information with the registrar.

    By giving the Hosts file the URL and the IP address the new site host’s gives you, you can check that things are working before “flipping the switch”.
    Then, when you’re sure it’s ready, you can flip the switch and remove the line from your Hosts file.
    Check out Advanced Website Testing via the HOSTS File

  10. Forgot to add earlier: thank you for the good post.

  11. Thanks for the guide. I already was solid on most things but this helped me double check. I appreciate it!

  12. I don’t have much technical knowledge and want your guidance –

    I have the ftp details for uploading to my wordpress blog, that’s all. If I want to change my host, since my blog is currently hosted on somebody else’s server, can I do that, considering that I wont get any support from my current host. I dont know how to back up my blog from cpanel since I don’t have one.

    Please help.