Skip to content

Instantly share code, notes, and snippets.

@CaroManel
Last active January 14, 2016 05:59
Show Gist options
  • Save CaroManel/1478c129d55df54289c4 to your computer and use it in GitHub Desktop.
Save CaroManel/1478c129d55df54289c4 to your computer and use it in GitHub Desktop.
Change url in wordpress when migrating a site
SET @old := 'http://oldsite.carol.local';
SET @chunk_old := '%oldsite.carol%';
SET @new := 'http://mynewsite.carol.local';
UPDATE wp_options SET option_value = replace(option_value, @old, @new);
UPDATE wp_posts SET guid = replace(guid, @old, @new);
UPDATE wp_posts SET post_content = replace(post_content, @old, @new);
UPDATE wp_postmeta SET meta_value = replace(meta_value,@old, @new);
/* It is always good to check if there is any other portings of url pointing to the old site */
select option_value from wp_options where option_value like @chunk_old;
select guid from wp_posts where guid like @chunk_old;
select post_content from wp_posts where post_content like @chunk_old;
select meta_value from wp_postmeta where meta_value like @chunk_old;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment