At some point or another almost everyone will have to live through the horrible experience of moving a WordPress install to a different server. Usually this will result in some loss of readership, mostly because of downtime. There is, however, a simple and easy way to move without suffering any downtime whatsoever. The magic ingredient lies with MySQL.
**Note: The instructions following are for users who use the CPanel control panel software on their server. If you use a different piece of control panel software the procedures listed (mainly step 2) may be different… These instructions also assume your DNS info is changing as well.
Order a new server
Step one is to obviously set up a new server. Do not get rid of your old hosting package yet and do not delete the files off the old server, doing so will result in immediate downtime (which is the mistake most people make).
After you have a new server, copy all of your files, databases, configuration settings, etc over to the new server (or have your host do it for you, many do it for free), but leave your old server as-is.
Set up the new server for remote MySQL connections
Go onto your new server’s control panel and click on the “MySQL databases” section. Scroll to the bottom where it says “access hosts” and add your old server’s IP address to the box. If you don’t know the old IP, contact your host or dig through your e-mail boxes and try to find the initial “welcome to … hosting” e-mail (you saved that, right?). You can also use a tool like Domain Tools to look it up if your DNS changes haven’t gone through the net yet.
If your host is not using the CPanel suite, check their support pages to see if it is possible to set up remote MySQL connections. Either way, you want to allow remote connections from your old server.
Also, take note of your new server’s IP address, as you will need that for the next step.
Change the config file on the old server
The next step is to change where WordPress looks for the MySQL database in your old server’s WordPress configuration file. The file, called WP-config.php, is located in your blog’s installation directory.
The line you are looking for will look something like this:
define("DB_HOST","localhost");
Simply change localhost to the IP address of your new server, and click save.
What does this do?
All this does is tell WordPress to connect to your new server’s MySQL server instead of “localhost” (your old server). If set up properly, your blog will have zero downtime when switching servers or hosts and you will be able to add new posts, even when the DNS has not yet propagated across the ‘net.
If a visitor’s ISP has yet to update their DNS info and they log onto your site they will actually be visiting your old server and not the new one. With these changes they will see all of the new posts, comments, etc so you can go about business as usual.
What about posted images?
Well, there is one bad part about this. If you write a new post and add an image, it may or may not appear. The best way to avoid that is to not attach images for a couple of days.
Will this work with other CMS’s?
Pretty much every modern content management system these days allows you to configure the MySQL host it connects to, so yes, these same procedures will work. Just remember, uploaded data (like images or files) to your new server may or may not be available to everyone for a day or two.
Please subscribe, or else I will cry. Do you really want to make a programmer cry?

Leave a Reply