Migrating Your Wordpress blog to a New Server
is not quite as easy as it could be. (or, maybe i just did it the hard way — i do that sometimes.)
follow these steps for a clean, if not necessarily painless, migration:
- dump the WP database from your old server to a file:
mysqldup -u username -ppassword databasename > dump.sql - download and unpack (but do not “install”) WP on your new server: http://wordpress.org/download/
- rename
wp-config-sample.phptowp-config.phpand fill it in with your new database, username, and password. - if you used a non-standard table prefix in the MySQL tables on your old server, be sure to use the same prefix in your
wp-config.phpor your new install won’t see your old data - install wordpress (load http://your-site.com/wp-admin/install.php in a browser)
- here’s where the annoying part starts — the default WP install creates some dummy posts, comments, etc. to illustrate to the user what their blog will look like populated with data. this is a nice touch, but it’s annoying because unless you remember that MySQL supports REPLACE (which i of course forgot), you’ll soon find that loading in your old WP data will collide with the dummy data in your new install. At this point you have two choices: either 1, delete the default offending rows in your database to “get them out of the way”
mysql -u username -ppassword databasename
DELETE FROM wp_posts;
DELETE FROM wp_links;
…
and then load your data into clean tables (the ones you care about arecodeblog_categories, codeblog_linkcategories, codeblog_links, codeblog_post2cat, codeblog_postmeta, codeblog_posts, andcodeblog_comments(maybe - i deleted my comments because they were mostly spam), or 2, comment out (with a –) the duplicate lines in your SQL dump so they don’t collide with the WP sample data. odds are there will only be a few lines you need to comment out — WP seems to just create one sample post, one sample comment, a bunch of sample links, and a sample category. the problem with commenting out, i.e. not loading those lines is you’re actually omitting those entries from your old blog. so actually, that’s not such a good idea after all. - you’re done — log in and you should be solid.
i’ll upload a SQL script that clears the table for you — i made one to make this process simpler.