Migration Specific SQL Queries
How to Change SITE URL and HOME URL
WordPress stores the absolute path of the site URL and home URL in the database. Therefore, if you transfer your WordPress site from the localhost to your server, your site will not load online. This is because the absolute path URL is still pointing to your localhost. You will need to change the site URL and the home URL in order for the site to work.
Solution:
update wp_options set option_value =’https://yourwebsiteurl.com’ where option_name=’siteurl’ or option_name =’https://yoursiteurl.com’;
How to Change GUID
After you have migrated your blog from the localhost to your server or from another domain to a new domain, you will need to fix the URLs for the GUID field in wp_posts table. This is crucial because GUID is used to translate your post or page slug to the correct article absolute path if it is entered wrongly.
Solution:
update wp_posts set guid=replace(guid,’https://oldsite.com’,’https://newsite.com’);
How to change URL in Post-contents
WordPress uses absolute path in the URL link instead of a relative path in the URL link when storing them in the database. Within the content of each post record, it stores all the old URLs referencing the old source. Therefore you will need to change all these URLs to the new domain location.
Solution :
update wp_posts set post_content= replace(post_content,’https://oldsitename.com’,’https://newsitename.com’)
Change Image Path Only in Post Content
By default wordpress store absolute path of the relative images and this create a lots of problem whenever we change our server. SO how to change the image paths stored in the post contents
Solution:
update wp_posts SET post_content = REPLACE (post_content, ‘src=”https://www.oldsit.com’,’src=”https://newsite.com’); The above query only change the source of images not the attachments available with that post, So issue the following query also along with the above one.
UPDATE wp_posts SET guid = REPLACE (guid,’https://www.oldsite.com’,’https://newsite.com’) WHERE post_type = ‘attachment’;
Update/Change Post Meta
Post meta is also stored as the same way as your post image and other URLs ie, absolute path, so change them according to new website address
Solution:
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value,’https://www.oldsit.com’,’https://www.newsit.com’);
Please read these commands carefully. Alternatively you can google for sql queried for wordpress administrator.