/* Replaces URL in WordPress Home and Site URL in wp_options */
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsite.com', 'http://www.newsite.com') WHERE option_name = 'home' OR option_name = 'siteurl';
/* Replaces URL in GUID of all posts/cpt/etc */
/* https://deliciousbrains.com/wordpress-post-guids-sometimes-update/ */
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldsite.com','http://www.newsite.com');
/* Replaces URL within all posts/cpt/etc content */
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldsite.com', 'http://www.newsite.com');
/* Replaces URL within all posts/cpt/etc metadata */
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.oldsite.com', 'http://www.newsite.com');
/* Replaces URL in WordPress Links */
UPDATE wp_links SET link_url = replace(link_url, 'http://www.oldsite.com', 'http://www.newsite.com');
/* Replaces URL in WordPress Image Links */
UPDATE wp_links SET link_image = replace(link_image, 'http://www.oldsite.com', 'http://www.newsite.com');
/* Replaces URL in WordPress Users Website URL */
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'http://www.oldsite.com', 'http://www.newsite.com');
/* Replaces URL in WordPress Comment Authors */
UPDATE wp_comments SET comment_author_url = REPLACE(comment_author_url, 'http://www.oldsite.com', 'http://www.newsite.com');
/* Set our Old and New URLS */
SET @oldurl := "http://www.oldsite.com";
SET @newurl := "http://www.newsite.com";
/* Replaces URL in WordPress Home and Site URL in wp_options */
UPDATE wp_options SET option_value = replace(option_value, @oldurl, @newurl) WHERE option_name = 'home' OR option_name = 'siteurl';
/* Replaces URL in GUID of all posts/cpt/etc */
/* https://deliciousbrains.com/wordpress-post-guids-sometimes-update/ */
UPDATE wp_posts SET guid = replace(guid, @oldurl, @newurl);
/* Replaces URL within all posts/cpt/etc content */
UPDATE wp_posts SET post_content = replace(post_content, @oldurl, @newurl);
/* Replaces URL within all posts/cpt/etc metadata */
UPDATE wp_postmeta SET meta_value = replace(meta_value, @oldurl, @newurl);
/* Replaces URL in WordPress Links */
UPDATE wp_links SET link_url = replace(link_url, @oldurl, @newurl);
/* Replaces URL in WordPress Image Links */
UPDATE wp_links SET link_image = replace(link_image, @oldurl, @newurl);
/* Replaces URL in WordPress Users Website URL */
UPDATE wp_usermeta SET meta_value = replace(meta_value, @oldurl, @newurl);
/* Replaces URL in WordPress Comment Authors */
UPDATE wp_comments SET comment_author_url = REPLACE(comment_author_url, @oldurl, @newurl);