Generalized, here’s the process I used to move Waffle from my old host to my new host:
- ‘Dump’ the database - saving everything into the SQL queries needed to re-construct the database. This is available from the excellent online database manager PHPMyAdmin or the bundled command line tool mysqldump.
- Download all the files from the old server (fairly naturally). (It’s important to do the database dump the very first thing you do before this step; if it takes a long time and your old host close on you, there’s a fair chance there’ll be database data you won’t have, but there’s a good chance you already have your files on your hard drive.)
- At this stage it might be tempting to upgrade to a newer version of WordPress immediately. However, I recommend getting your current version up and running first, if for no other reason than to see that everything basic still works. So, instead of upgrading right now, edit wp-config.php to point to your new database (create this new database using your host’s admin tool if you haven’t already).
- Upload the old files to the new server.
Restore the database. Possible tools include:
- The aforementioned PHPMyAdmin
- The mysql command line tool on the new server (via ssh or telnet)
In combination with the uploaded dump called “tempfile”, a simple PHP script along the lines of
<
?php mysql_connect(host, name, password); mysql_select_db(database); mysql_query(implode('',file("tempfile"))); ?>(For many reasons such as security and not running it again after two months having it duplicate everything, remember to delete the script and the uploaded dump (”tempfile”) immediately after it’s been run.)
If you’re changing the URL of your set up, remember to take these steps:
- In the
optionstable, change the row with theoption_name“siteurl” to have theoption_valueof your new URL. (If a row exists with theoption_name“home”, change that one too.) - If you can have an
.htaccessfile (if you’re on Apache) and you use the Permalink Structure feature to make nicer URLs, make sure that file gets rewritten by re-saving it. (Remember to set the correct permissions of the.htaccessfile, since normal permissions will not normally allow WordPress to rewrite the file.) If you have
mod_redirect, use this.htaccessfile in your old URL root to redirect any request to that URL to the new URL:RewriteEngine On
RewriteRule ^/(.*)$ http://your.old.url$1If your new path is not at the root of a domain, insert
RewriteBase /path/to/new/pathin between. (Be sure to leave off the trailing slash.)