Skip to content

Instantly share code, notes, and snippets.

@raae
Last active August 29, 2015 14:23
Show Gist options
  • Save raae/e9e24321589cac7b6e6d to your computer and use it in GitHub Desktop.
Save raae/e9e24321589cac7b6e6d to your computer and use it in GitHub Desktop.
SQL updates when base url change in Wordpress
/* Do for each site */
/* x is site number, for site 1 omit "_x" */
UPDATE `wp_x_options` SET `option_value` = REPLACE(option_value, "old_domain", "new_domain");
UPDATE `wp_x_comments` SET `comment_author_url` = REPLACE(comment_author_url, "old_domain", "new_domain");
UPDATE `wp_x_postmeta` SET `meta_value` = REPLACE(meta_value, "old_domain", "new_domain");
UPDATE `wp_x_posts` SET `post_content` = REPLACE(post_content, "old_domain", "new_domain");
UPDATE `wp_x_posts` SET `guid` = REPLACE(guid, "old_domain", "new_domain");
/* Do once */
UPDATE `wp_blogs` SET `domain` = REPLACE(domain, "old_domain", "new_domain");
UPDATE `wp_site` SET `domain` = REPLACE(domain, "old_domain", "new_domain");
UPDATE `wp_sitemeta` SET `meta_value` = REPLACE(meta_value, "old_domain", "new_domain");
UPDATE `wp_usermeta` SET `meta_value` = REPLACE(meta_value, "old_domain", "new_domain");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment