Here’s some cool mysql scripts templates that you can use to update your database with the new domain name that’s in all those urls on your website. Reference website: https://wpbeaches.com/updating-wordpress-mysql-database-after-moving-to-a-new-url/
CAUTION: BACKUP DATABASE FIRST AND DON’T DO UNLESS YOU KNOW WHAT YOUR DOING.
- Before I get to the update scripts, from your website, confirm where the issues are. Click on the link that points to wrong url and look at the url path. For images that are corrupt, you can look in WP admin and see what the image path is. If you see that in all these issues you just need to replace the domain name, you can move on to Step 3. If you see something weird like this url excerpt example, try step 2 first.
- I would recommend to run SELECT scripts to confirm you make all necessary changes. For example, I found that if your domain name is pointing to a subdirectory, your database may reflect something like this database excerpt example: ‘http://rootdomainname.com/subdirectorydomainname.com/’. If you run these SELECT scripts first, you’ll be able to capture all domain name issues and modify the UPDATE scripts appropriately.
SELECT option_value from wp_options where option_value like ‘%http://rootdomainname%’;
SELECT guid from wp_posts where guid like ‘%http://rootdomainname%’;
SELECT post_content from wp_posts where post_content like ‘%http://rootdomainname%’;
SELECT meta_value from wp_postmeta where meta_value like ‘%http://rootdomainname%’;
- Here’s the update scripts:
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’);