Skip to content

Weblog Tools Collection: Moving Your WordPress Site and Database

April 3, 2010

There comes a time you may have to leave one web host for another. No matter the reason the idea of relocating an entire website – especially one that has been online for sometime – can seem very daunting. With a WordPress based site – I found it easier than expected – way easier.

My WindowsObserver.com website has 1,100 posts, 9 pages, 4 categories, 2,436 comments, uses 17 widgets, and has 35 active plug-ins. On top of all those elements I use Windows Live Writer to create all of my content and I use a good bit of screenshots and graphics in my posts. As a result I have over 40MB of images (1,100 files) to go along with my 1,100 postings.

Now for the purposes of this story I am not going to get into a comparison of hosting services or the like. The landscape is massive out there and confusing enough. You do not need me adding to it here :-)

I will also make a few other caveats/assumptions:

  • This is also based on a self-hosted WordPress site. I am not sure if this works on WordPress.com. If anyone has tried it please comment.
  • That you know the basic workings of a WordPress site such as plug-ins, directory structure, etc.
  • That you have FTP access to your host and therefore your WordPress files.
  • That you have access to your host to create the database and user account details for it. I will talk about phpMyAdmin because that is what my host uses. You may have a different way to access/create your database.
  • That you know how to update your websites DNS info with your new host so that people can find it at its new location.
  • I will only talk about one WordPress backup plug-in and that is WP-DBManager by Lester Chan. I know and understand there are others out there but this is what I used.

So with all that said here is how I dealt with a move between hosts:

  1. I backed up my current sites database using the WP-DBManager plug-in. If you use the defaults for the plug-in the backup will be stored in a sub-directory of the /wp-content/ directory called backup-db.
  2. I then launched my FTP software and downloaded the entire site to a temporary folder on my hard drive.  You need to make sure you grab the entire structure of your WordPress site.
  3. While the download was happening I went to my new host and created a new MySQL database and user. You could always use the same details as your old host but sometime the prefix for the database name can not be changed. I recommend a fresh database name and password just for good security practices. Make sure you also get the name of the database server. You will need all of this data to get your WordPress site working on the new host.
  4. I then created my domain at the new host using their control panel. At this point I did not do anything with DNS. Don’t worry though – creating your domain at the new hosts will do nothing more but prep a directory for you to access and upload your files to.
  5. After the files were downloaded from my old host I placed an index.html file in the old sites main directory with a simple message that the site was being relocated. You can be as fancy or in depth as you want.  I then named my WordPress index.php to index.bak so there are no conflicts between the two. This also comes in handy as the DNS shift happens because people will see your site in its new location or the moving page. Once they no longer see the moving page then they will be good to go on the new location/host. It is a great tool for seeing the DNS shift in action.
  6. I then updated my wp-config.php file on my local hard drive to reflect the database information for the new host. if you have set up a WordPress site before you know how to do this already.
  7. Now it was time to upload all the files to my new host from the local hard drive keeping the exact same directory structure.
  8. Once the files were uploaded I updated my registrar’s DNS info for the new host and location of my site.

They say a DNS shift can take up to 48 hours to propagate around the Internet and your mileage may vary for how quick you see the update yourself.  About 30 minutes after I entered the new DNS info at my registrar I flushed my local machines DNS info and was able to see the site at the new address at that point.

To flush your DNS you need to open a command.com window and type in “ipconfig /flushdns” without the quotes. If you then ping your websites URL and see it reply back with the new hosts IP address then you will be able to browse your site at its new location once everything is setup there. If it comes up with the old hosts IP address then there is nothing you can do but wait for the DNS update to get around.

Now for the database move/restoral.  Some hosts restrict the size of files you can upload so you need to be aware of that for your host in these next steps. However, I am going to provide two options for restoring your database. One takes a working knowledge of phpMyAdmin or a similar MySQL database interface – the other makes use of the WP-DBManager plug-in to restore the database and site.  The plug-in method can be used for small size databases as well as large ones.

Restore your database using phpMyAdmin or similar MySQL database interface:

  1. I logged into my host and from the control panel I accessed phpMyAdmin logging into the interface using the credentials I created for the sites database.
  2. I then went to the Import tab, browsed to the temporary directory on the hard drive where my WordPress site files were stored and went into the /wp-content/backup-db/ directory to find the backup copy of my latest version of the database. Once selected I then left everything at its default settings and clicked the Go button to import the database structure.
  3. That is it – the database is now present on your new host in the new database. If your DNS is updated and everything is uploaded you should be able to type your websites address in a browser and it will come up just like it did before the move.

Restore your database using the WP-DBManager Plug-in:

In order to use this method your DNS has to be moved so you can access your site at the new host.

  1. Browse to your websites address and you should be prompted to create your new site just like when you do a fresh install of WordPress. Type in your sites title and your email address and then go the the next step. You will be provided the temporary password for the admin account.
  2. Log into this WordPress install and then activate the WP-DBManager plug-in. Do not worry about activating other ones. Then use this plug-in to restore the copy of your database that should have been uploaded to your new host with all the other files. It will be in that /wp-content/backup-db/ directory.
  3. Once that database restores your site will be up and running with plug-ins activated, the same theme, etc.

You will likely still need to tweak a few things like file and folder permissions but if you got the entire directory structure uploaded and restored the entire database your site will be there just like on the old host.

As always, your comments about your own experiencing in this process and the tools you used are always welcome – in fact we look forward to them and the community sharing your unique experience. There is always someone else out there looking for similar info.

Comments are closed.

%d bloggers like this: