I was recently asked by a friend to help move her WordPress-run site to a new host. It was not just a simple matter of making a new installation of WP at the new host, but also moving old posts, and retaining the look and structure of the blog.
This is something that a few people must be encountering, and while there are detailed instructions at the WP Codex on how to backup a database, install WordPress, and reinstate your posts, it can be a little scary for a first timer. (I don’t consider myself a WP newbie, but I did do some very silly things in a process that can be achieved with minimal pain.)
So here’s my quick guide to moving your Word Press site to a different location, incorporating all that I learnt from the experience in one place!
Step 1: Back up your database, theme, plugins
Backing up your database is not as scary as it sounds, especially if you have the WP Backup plugin. If so, you’re probably being a good girl/boy and backing up your tables regularly.
But even if not, a backup can be easily done through PHPMyAdmin, accessed via the control panel at your hosting account. Select the Word Press tables in your database and go to the “Export” tab. Select the “save as file” box and download the backup to your computer. You should be having a .sql file. If you selected to compress, you’ll have a zipped/gzipped version of it.
Right. Now your posts, comments, etc. are safe.
You also need to backup your theme files, and any plugins you use.
Step 2: Recreate the WP database at the new location
Using your control panel, create a new MySQL database at your new host’s, adding a user and password. Go to PHPMyAdmin, select the database, and then click on the SQL tab. Copy and paste the data from your .sql backup file in the box provided. (Alternatively, use the “Show location of textfile” option: click on browse and point it to the .sql backup file). Now go get some coffee while the query executes. Sometimes it can take a while.
Step 3: Install Word Press at the new location
Upload all the files to your new location. Remember to rename config-sample.php to config.php, and put in your new database settings (database name, username, and password). Also upload your theme files (to the wp-content/themes folder) and plugins (to wp-content/plugins folder).
Step 4: Type in the URL of your site and press Enter/Return
Yes, you’re mostly done :-). At this point you may notice that clicking on your posts or archives is returning an error. This is the case if you had a custom permalinks structure. You need to update your .htaccess. Log in to the dashboard. Go to Options –> Permalinks. Update the permalinks. If Word Press cannot rewrite to your .htaccess, it will tell you exactly what to put in there. Use this data to update your .htaccess manually.
And now you are done!