Skip to content

Instantly share code, notes, and snippets.

@huzaifaarain
Created May 10, 2021 20:40
Show Gist options
  • Save huzaifaarain/ece8782371dd12b64385a9c867c5bb4b to your computer and use it in GitHub Desktop.
Save huzaifaarain/ece8782371dd12b64385a9c867c5bb4b to your computer and use it in GitHub Desktop.
Update WP Links In Database After Migration
SET @oldUrl = "Existing URL" COLLATE utf8mb4_unicode_520_ci;
SET @newUrl = "New URL" COLLATE utf8mb4_unicode_520_ci;
UPDATE wp_options SET option_value = replace(option_value, @oldUrl, @newUrl) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, @oldUrl, @newUrl);
UPDATE wp_postmeta SET meta_value = replace(meta_value,@oldUrl, @newUrl);
UPDATE wp_usermeta SET meta_value = replace(meta_value, @oldUrl, @newUrl);
UPDATE wp_links SET link_url = replace(link_url, @oldUrl, @newUrl);
UPDATE wp_comments SET comment_content = replace(comment_content , @oldUrl, @newUrl);
UPDATE wp_posts SET post_content = replace(post_content, @oldUrl, @newUrl);
UPDATE wp_posts SET guid = replace(guid, @oldUrl, @newUrl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment