Change the Domain of a WordPress Site Using This MySQL Command

Use the following MySQL commands to change the URL of your WordPress website. You will need to modify the old and new domains in the code as well as the database prefix (wp_).

Change Your WordPress Site Domain

UPDATE wp_options SET option_value = replace(option_value, 'https://old.example.com', 'https://new.example.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'https://old.example.com', 'https://new.example.com');

UPDATE wp_posts SET post_content = replace(post_content, 'https://old.example.com', 'https://new.example.com');

UPDATE wp_postmeta SET meta_value = replace(meta_value, 'https://old.example.com', 'https://new.example.com');

Next Steps