Moving a WordPress Install from one Domain (A) to another Domain (B)

From time to time I had have to move one installation of WordPress from one domain (let’s call it domain A) to a new domain (let’s call it domain B). Because WordPress embeds the domain all over the data schema (not faulting; simply disclosing) you have to make a lot of dB changes for the updated site location to function. Here is the quick and dirty way to move the data:

UPDATE wp_posts SET post_content = REPLACE(post_content,"[OLD_DOMAIN]","[NEW_DOMAIN]");
UPDATE wp_posts SET guid = REPLACE(guid,"[OLD_DOMAIN]","[NEW_DOMAIN]");
UPDATE wp_options SET option_value = REPLACE(option_value,"[OLD_DOMAIN]","[NEW_DOMAIN]");
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value,"[OLD_DOMAIN]","[NEW_DOMAIN]");

Finally, for the final bit of trickery if you are using Advanced Caching on the site there is a great place where the localized PATH is hard coded. Edit your new and updated path on file advanced-cache.php

vi wp-content/advanced-cache.php

1 Comment so far »

  1. Alex Prokopenko said

    October 8 2009 @ 1:22 am

    Nice solution for developers and advanced users, but it’s not 100% correct.
    wp_options table can contain serialize arrays in “option_value” column and if you replace the string inside – you lose data in this cell.
    JustCoded Team has created simple script to help users, clients and developers to move their WordPress installation.

    You can find it here:
    http://justcoded.com/article/wordpress-tips-moving-site-to-another-server/

Comment RSS · TrackBack URI

Leave a comment

Name: (Required)

Email: (Required)

Website:

Comment: