Home » cPanel » Update WordPress URL’s after domain change

Update WordPress URL’s after domain change

WordPress stores all its data like: posts, pages, profiles and configuration in the MYSQL database. If you moved your WordPress site to a different folder or the site domain name has changed, you will need to update the WordPress URLs in various MySQL database tables.

Let’s see the steps you have to follow to update site URL’s throughout the database.

Step 1 — Find Out WordPress Database Name

WordPress stores MySQL database name and its credentials in wp-config.php file. This file is located in your root WordPress file directory. You can access this file using File Manager or FTP Client.

config-Update WordPress URL's after domain change


Now open wp-config.php file and search for 'DB_NAME'.

Step 2 — Entering phpMyAdmin

Next, access phpMyAdmin from your control panel.

phpmyadmin-Update WordPress URL's after domain change

Step 3 — Selecting the Correct Database.

On the left side of phpMyAdmin, you can see a list of all existing databases. Select the correct MySQL database from the list which is connected to your WordPress website.

Step 4 – Formatting SQL Query

Click on SQL section in phpMyAdmin and enter the following code:

UPDATE wp_options SET option_value = replace(option_value, 'oldurl.com', 'newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'oldurl.com','newurl.com');

UPDATE wp_posts SET post_content = replace(post_content, 'oldurl.com', 'newurl.com');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldurl.com','newurl.com');


This code will replace all instances of oldurl.com to newurl.com in the database.

Note that  Sometimes table prefix can be different than wp_. You have to use the correct table prefix in the above SQL code. You can see table prefix on the left side of phpMyAdmin, under your WordPress database:

Here table prefix is wpqc_.

Step 5 – Running SQL Query

Once you replaced URLs and table prefix you can run your query. In order to run your queries click on GO button which is located on the bottom right.

Step 6 – Verifying The Successful Change of URLs

If the query was executed successfully, you will see a green success message as follows:

Note that the number of rows will be different for each WordPress website.

To verify changes open wp_options table and check your home and siteurl values. You should see new WordPress URLs from the SQL query.


That’s it!!


Leave a Reply