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
- After selecting your database, click on the SQL tab.
- 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
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]