Steps involved in to migrate the WordPress site to a new domain

Follow the steps below to migrate the WordPress site to the new domain. You will find the database queries to execute for changing the URLs and site links. These queries are very helpful if you migrate your site to a new domain without a plugin.

  1. Open the PHPMyAdmin,
  2. select the database to replace the site URL
  3. Go to the SQL tab
  4. Paste the given queries
  5. Execute the queries by Go button
PHPMyAdmin to change DB Queries to migrate site and change old domain to new domain
phpMyAdmin – Database queries to migrate the site to the new domain

Database queries to migrate WordPress site to a new domain

The below queries will replace the existing(old server) server link from the URLs and the post content with the new server link

  1. UPDATE wp_options SET option_value = replace( option_value, ‘https://old_site_domain’, ‘https://new_site_domain’);
  2. UPDATE wp_posts SET guid = replace( guid, ‘https://old_site_domain’, ‘https://new_site_domain’);
  3. UPDATE wp_posts SET post_content = replace( post_content, ‘https://old_site_domain’, ‘https://new_site_domain’);
  4. UPDATE wp_postmeta SET meta_value = replace( meta_value, ‘https://old_site_domain’, ‘https://new_site_domain’);

Database queries To change the HTTP version of the old domain

Sometimes there are some entries that have the links containing HTTP version old site, like http://…, so you should also need to replace those entries while migrating the wp site domain.

  1. UPDATE wp_options SET option_value = replace( option_value, ‘http://old_site_domain’, ‘https://new_site_domain’);\
  2. UPDATE wp_posts SET guid = replace( guid, ‘http://old_site_domain’, ‘https://new_site_domain’);
  3. UPDATE wp_posts SET post_content = replace( post_content, ‘http://old_site_domain’, ‘https://new_site_domain’);
  4. UPDATE wp_postmeta SET meta_value = replace( meta_value, ‘http://old_site_domain’, ‘https://new_site_domain’);

Queries to replace the Yoast SEO Plugin entries

If you have the Yoast SEO plugin installed for managing your site ranking. then you can replace the following entries too. Be careful about this replacement as it is actually associated with your site’s SEO score(ranking). Following database entries may cause a severe impact on your SEO score. as this may replace your existing canonical URL. The canonical URL is used by the search engine to identify the URL of your post. This prevents the search engine from indexing duplicate content.

  1. UPDATE wp_yoast_indexable SET permalink = replace( permalink, ‘https://old_site_domain’, ‘https://new_site_domain’);
  2. UPDATE wp_yoast_indexable SET twitter_image= replace( twitter_image, ‘https://old_site_domain’, ‘https://new_site_domain’);
  3. UPDATE wp_yoast_indexable SET open_graph_image= replace( open_graph_image, ‘https://old_site_domain’, ‘https://new_site_domain’);
  4. UPDATE wp_yoast_indexable SET open_graph_image_meta= replace( open_graph_image_meta, ‘https://old_site_domain’, ‘https://new_site_domain’);

These are the main database entries you should replace while migrating the WordPress site. Those work for most of the wp sites. but, there might be some more plugins or customization on your site which may need to address.

All the above replacement entries for the wp site migration are given assuming that you are using the HTTPS version of the site, just replace https with http if you are using the non-SSL site.

One Response

Your feedback is highly appreciated!