Sep 01, 2023   ,

When you import databases from an old backup, perhaps you need to change the site URL and there’s a quick and easy way to make it in MYSQL via PHPMyAdmin.

The first step is to import the databases.

The following code needs to be applied for three tabs: wp_options, wp_posts, wp_postmeta.

Click on each of these tabs and on the column SQL.

Now add the code below where instead of http://www.oldurl you put the old URL you want to change and http://www.newurl the one you want to change it with

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

Once you have changed the details, hit Go and repeat for each of the tabs above mentioned.

*** This tutorial is based on one I found here.