How to Change WordPress URLs in MySQL Database

Author: Kenneth ([email protected])

Published: Sunday April 4, 2021

Wanted to create a test environment (UAT) for my blog after my site was launched to isolate plugin updates and other miscellaneous changes. Copied all the folders and created a new website. Issue was that I had to change the URLs in MySQL for my test environment to work. Thanks to the solution here! Reposting it below.

UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, '','');
UPDATE wp_posts SET post_content = replace(post_content, '', '');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'','');

Replace with your current WordPress address and with your new WordPress address.