Posted by & filed under WordPress.

The following set of instructions will encapsulate your WordPress data into a dump file you can transfer to a different host (if applicable), and then update all WordPress database references to point to your new domain (including all of the images you have attached to your posts and pages).

The following set of instructions will encapsulate your WordPress data into a dump file you can transfer to a different host (if applicable), and then update all WordPress database references to point to your new domain (including all of the images you have attached to your posts and pages). Before proceeding, you will need to know the database collation (language) your database is using to avoid having unreadable characters show up across your site. The most common collations are latin1_swedish_ci and utf8_general_ci. The “ci” is short for case insensitive which allows you to conduct queries in an case insensitive manner. You will also need to have SSH access to run the mysqldump command. You can use phpMyAdmin to export your data, but we have not found a way to set the equivalent of the “default-character-set” mysqldump flag, which means there is the potential that you will get unreadable characters appearing on your new host if there is some sort of collation mismatch somewhere. These instructions will assume that you have SSH access.

Transferring Data To a Different Server (if applicable to you)

  1. mysqldump -h <dbhost> -u <dbuser> -p –default-character-set=<latin1 or utf8> <databasename> > mydumpfile.sql
  2. authenticate using the MySQL password for <dbuser>
  3. transfer this file (mydumpfile.sql) to your new host. We suggest using scp (secure copy), since this is quick and easy (scp mydumpfile.sql username@host:)

Updating Your Domain Used by WordPress

Run the following SQL to find and replace instances of your old domain name and replace it with your new one:

UPDATE wp_options SET option_value = REPLACE(option_value, 'http://yourolddomain', 'http://yournewdomain')
WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = REPLACE(guid, 'http://yourolddomain','http://yournewdomain');

UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://yourolddomain', 'http://yournewdomain');

These queries can be run within phpMyAdmin or the MySQL command line.