First step: Files and Database(s) backup
Before doing any modification to the actual database. we recommend you to make a backup of all your files and database(s) on your hosting.
Second step: Replace old website reference.
In those examples, we use ‘https://www.old-site.com’
as our current/old website, and 'https://www.new-site.com' as the new one we want to change
Every modification described within this tutorial will be made on the database.
The first command to use is:
UPDATE wp_options SET option_value = replace(option_value, 'https://www.old-site.com', 'https://www.new-site.com') WHERE option_name = 'home'
OR option_name = 'siteurl';
Third step: Replace relative URL from posts.
This step consists of changing all the URL in the wp_post table.
UPDATE wp_posts SET guid = replace(guid, 'https://www.old-site.com','https://www.new-site.com');
Fourth step: Replace URL from posts contents
Just to be sure every reference to your old URL doesn’t appear in any post content,
You must run this last command:
UPDATE wp_posts SET post_content = replace(post_content, 'https://www.old-site.com','https://www.new-site.com');
Once all those modifications were done, you will able to use the new URL.
Be sure to clear your browser cache