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, 'oldurl.com', 'newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace(guid, 'oldurl.com','newurl.com'); UPDATE wp_posts SET post_content = replace(post_content, 'oldurl.com', 'newurl.com'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldurl.com','newurl.com');
Replace oldurl.com with your current WordPress address and newurl.com with your new WordPress address.