WordPress uses MySQL database to store all its data, including site URLs. So if for some reason you need to change your WordPress URL, it’s necessary to tweak some data in MySQL. Keep reading to know how to do it!

1. Determining the Name of WordPress MySQL Database

You can skip this part if you only have one MySQL database. However, if you have multiple databases and not sure which one is connected to WordPress, then follow the steps below.

WordPress stores MySQL database name and its credentials in the wp-config.php file. You can find this file in your root file directory:

1. Access your cPanel and open File Manager.

a0bb816df48b394717ac675591f5876ebeaa2864?t=e9f1951699807c56a14179fc19dbe17f
2. Select the domain name or Public_html folder, there you should see the wp-config.php file.

7e55cafe2ff806444d04c7394b18bcdd583c6757?t=5188d965786f0d097acab0c78c0a38b1
3. Open wp-config.php and search for DB_NAME. The value of this parameter is your database name. For instance, the name of our MySQL database in this is ouqqndmx_wp369.

60cace61e6cfc54b70286a8d2b3346e73a35dd61?t=a95d1cbf97933913e1ea26926a20c64b
2. Changing WordPress URLs in MySQL Database


Replacing your old URL is not difficult at all. Here’s what you need to do:

Go to phpMyAdmin via your website control panel.

ab42081f710632f058e5c068c248c5981bb10f74?t=c00a2f04329e49636ffef7138b9f1426
The left panel list all of your databases. Select the one connected to your WordPress site and head to the SQL tab.

c7e1b4dde9cbabee202a0910b88141a29bbaa5ef?t=fe0827e2d8e82b03dad275d0ed55ecb0
Enter the following SQL query:



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');



It should look like the example below:

d2648ddcd3487cec5e2775af32eb3788f1a7e58e?t=ae89a22b5fae1a5413022d37a7ca497b

IMPORTANT: Replace oldurl.com with your current WordPress address and newurl.com with your new WordPress address.

Also, important to note: your table prefix might not be wp_. See the correct table prefix on the left panel of phpMyAdmin, and update the SQL query.


4. Press Go. You will see success messages along with the number of changed rows. Note that the number of rows will be different for each WordPress website.

5. The last thing we need to do is verify the changes. Open the wp_options table and check the option_value of siteurl and home. You should see your new URL.

45fc8cab1d5b2dd4650e27d596f86980b11a0ea7?t=209d6562ab94faf4c1286a05d938f78b
If you get error messages and the queries are not executing, check your code for syntax errors and make sure you are using the correct table prefix. Contact the hosting support for further assistance if the error persists.

Conclusion


We just learned how to change WordPress URLs in the MySQL database using phpMyAdmin.

As we can see, all the steps above are quite straightforward. You just need to determine the correct database and then input some lines of code.

We hope this tutorial can give you clear guidance on how to change WordPress URLs in the MySQL database. Kindly leave any questions you have below!

Comments

Confirm Submission

Please enter the text from the image in the box provided; this helps us to prevent spam.