How to Update Your WordPress Installation After Changing URLs (Updated for WP 3 Multisite)
This is an update to this post now that WordPress 3 has come out.
I haven’t thoroughly tested this, but it’s working for me now. Also, this is for a multisite installation, so there are some tables that won’t exist if you have a single site.
SET @oldURL = 'oldsite.com'; SET @newURL = 'newsite.com'; update wp_comments set comment_content = replace(comment_content, @oldURL, @newURL); update wp_comments set comment_author_url = replace(comment_author_url, @oldURL, @newURL); update wp_postmeta set meta_value = replace(meta_value, @oldURL, @newURL); update wp_posts set post_content = replace(post_content, @oldURL, @newURL); update wp_options set option_value = replace(option_value, @oldURL, @newURL); update wp_links set link_url = replace(link_url, @oldURL, @newURL); update wp_blogs set domain = replace(domain, @oldURL, @newURL); update wp_site set domain = replace(domain, @oldURL, @newURL); update wp_sitemeta set meta_value = replace(meta_value, @oldURL, @newURL); update wp_usermeta set meta_value = replace(meta_value, @oldURL, @newURL);
Just be sure to change the @oldURL and @newURL variables to your domains. Also, in your wp-config.php, don’t forget to change the line that says:
define( 'DOMAIN_CURRENT_SITE', 'yourdomain.com' );
to the new domain.
Hope this helps. Drop a comment if I missed anything.
Categories: Web Development