Sometimes you may want to move your WordPress sites to different domain names, change the installation directory, or use your databases in WordPress installations with different domain names. After migration, since the old domain name is recorded in the database, your site will not work properly.
In this article, we will show step by step how to update the domain name in the database after a migration or import operation.

First, after logging into cPanel, we click the phpMyAdmin link.

Then on the phpMyAdmin page that opens, we follow the steps below in order.
- We select the WordPress database.
- On the page that opens, we click the SQL tab.
- A field where we can write SQL queries will open below. We write the following code in this field (you need to write your own domain names in the places that say oldsite and newsite). You can run all the code at once or separately.
UPDATE wp_options SET option_value = replace(option_value, ‘http://www.oldsite’, ‘http://www.newsite’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
UPDATE wp_posts SET guid = replace(guid, ‘http://www.oldsite’,‘http://www.newsite’);
UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.oldsite’, ‘http://www.newsite’);
UPDATE wp_postmeta SET meta_value = replace(meta_value,’http://www.oldsite’,‘http://www.newsite’); - Finally, we click the Go button to complete the update process.
After these operations, your database will work seamlessly with your new domain name.
Leave a Comment
* Your comment will be published after approval.
Comments
0No comments yet. Be the first to comment!