This weekend I started using a new web hosting provider, as the previous one was having too much downtime for my liking. A WordPress blog consists of

  • a lot of PHP files that provide the funtionality,
  • the files that have been uploaded to the blog,
  • and a MySQL database that stores all posts, pages, and sidebar links.

All this has to be copied to the new web host. To make things easier, I chose a hosting service that also provides cPanel.  The steps are rather straightforward and take only a few minutes (depending on the size of your blog), although it took me some hours to figure them out.

  1. Log into the cPanel of your old hosting service.
  2. In the file manager, select the directory containing your blog (public_html/michel/chezmichel in my case) and compress it into a zip file and then download it to your local machine.
  3. In the backup section of cPanel, download a backup of the database. If you created the blog with Fantastico, the database will be called OU_wrdpN, where OU is the username you were assigned by the old hosting provider and N is a number. After performing this step, you will have a file wrdpN.sql.gz on your local machine.
  4. Log out from your old host provider and log into the cPanel of the new one.
  5. In the backup section, restore the backup of the database. It will be called NU_wrdpN, with your new username NU which may be different from the OU username at your old provider. That’s OK.
  6. In cPanel’s file manager, recreate the same parent directory for the blog, if necessary (public_html/michel in my case). In that directory, upload the zip file from your local machine and uncompress it. This will restore all WordPress files that were in the old host provider into the same path on the new provider.
  7. While in the file manager, use the code editor to open the file wp_config.php that exists in the blog’s directory. You will see at the start of the file three lines similar to
    define('DB_NAME', 'OU_wrdpN');    // The name of the database
    define('DB_USER', 'OU_wrdpN');     // Your MySQL username
    define('DB_PASSWORD', 'rP9v[4AwLKxx'); // ...and password
    1. The first line tells WordPress which database is associated to the blog. Change OU to NU, if your new username is different  from the old username.
    2. The second and third lines define the username and password that WordPress will use to access and modify the database, to store new posts, pages, and links. If the blog was created by Fantastico, the username is the same as the database name, and the password is some random sequence of letters, digits and symbols. You can keep your old database username, but I preferred to also change OU to NU in the second line, to keep the username the same as the database name.
    3. Copy the password into the clipboard, i.e. select the password and press Ctrl-C.
    4. Save the changes to the file and exit the code editor.
  8. Go to cPanel’s ‘MySQL Databases’ section.
  9. Create a new database user with the same username and password as given in the wp_config.php file. Just press Ctrl-V to paste the password into the appropriate text field. Click ‘Create User’ to finish.
  10. On the right side of the same page, add the newly created user to the database restored in step 5 above. Click the ‘Submit’ button and in the new screen give all privileges to the new user.

That’s all it takes to transfer the blog! Note that these steps assume you have your own domain name for your blog and that you want to keep it, i.e. you just want to change where your blog is stored, not the URLs of any of your pages and posts. In that case, the only thing still to be done is to go to your domain name registrar and let it know which are the name servers of your new hosting provider. This change will take up to 48 hours to propagate through the internet, but once it’s done, whenever anyone types your blog’s URL into their browser, they will be transparently redirected to the new hosting provider. And since all the URLs were kept, any external pages and search engines will still point to your blog.

However, if you don’t have your own domain name, i.e. if your blog’s URL was something like http://blogname.oldhostingcompany.co.uk and will now be http://blogname.newhostingcompany.com, then my guess (I haven’t tried it out) is that, after step 3 above, you have to uncompress the database backup on your local machine, open the wrdpN.sql text file, do a global replace of the old URL by the new one, and compress the file again. You will also have to make the old URL redirect to the new one; this can be done in cPanel’s ‘Manage Redirects’ screen (in the old provider account, of course). In that way, in time search engines and other people will pick up your new URL. However, sooner or later you’ll want to close your old provider’s account, and then there’s no guarantee that someone’s links to your blog will be broken. Nothing beats having your own domain from the start.

One Comment to “Moving a blog to a new web host”

  1. [...] Backup the MySQL database containing your blog’s posts, pages, categories and tags, as explained in a previous post. [...]

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam protection by WP Captcha-Free