Chris Schuld's Blog

personal musings on the composition of software

Written By: Chris Schuld Monday, October 5th, 2009

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
Categories: WordPress

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

  1. 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/

Leave a Reply

About Chris

Chris Schuld

Thank you for visiting my website. I use this site for a myriad of things: maintaining software I have open sourced, connecting with my readers and friends and documenting all of this little things "I wished I would have written down." You can read more about me or contact me.


thanks for visiting... happy coding

Recent Comments