A great tip to remember is to backup your database every time before you do a direct database change.
What Tools You Will Need
Previously working in the website development industry for the past couple of years, I have had my fair share of transferring sites from my development environment over to my client’s live site. In most cases I used WP Migrate DB Pro which automatically does the rewrite for you.- Basic understanding of PHPMyAdmin or similar tool.
- cPanel access. (Please note FTP access won’t work for this guide).
- Time to complete: 5 – 10 minutes.
Change Your WordPress URL In The Database
Now that you have your website’s access details that is required for this guide, we can get into it! In this case, we will already restored our WordPress backup on the new domain using FTP or cPanel’s File Manager and we have imported the database backup and we need to do the final step in changing the WordPress website’s URL. 1. Navigate to your PHPMyAdmin of your website. This is usually done via cPanel or unique link. This may be provided by your hosting company.
PHPMyAdmin link in cPanel.

SQL Query in PHPMyAdmin Example
Please note that you will need to adjust the prefix wp_ to match those of your database you are editing. This is the default prefix used.
/**
* You are able to run the below SQL queries in order to change the WordPress URL in the database.
* This is useful when you are unable to use a WordPress plugin to migrate to a new domain (URL).
* For a guide on how to apply this code, please visit https://yoohooplugins.com/change-wordpress-url-database/
*
* Please be sure to replace wp_ with your database prefix.
* Simply change 'http://olddomain.com' to current URL
* Change 'http://newdomain.com' to the domain you are moving the WordPress website to.
*/
UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_links SET link_url = replace(link_url, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_links SET link_image = replace(link_image, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl' OR option_name = 'widget_text' OR option_name = 'dashboard_widget_options';
Simulate Query Results