How to Change WordPress URL in Database: Migrating Website from Demo to Live Server?

wordpress url update in mysql wordpress database table

WordPress uses a MySQL database to store information, including site URLs. If you want to change your WordPress URL, update it in MySQL. The question is why do you need to change url? There are several reasons to change the url but one of the most important reasons is when you are going to transfer or migrate your website from a demo or development server to a live or production server. This article will guide you through the process, so keep reading to learn how to do it.

Changing WordPress URLs in MySQL Database Tables

To change your current URL, follow these steps:

  1. Go to phpMyAdmin via your website’s control panel or any other third party mysql db connecting tools.
  2. The left panel check your installed or imported wordpress database. and click the one connected to your WordPress site and head to the SQL tab.
  3. Execute the following SQL query in SQL query panel:
    — 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’);

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

Important! Your table prefix might not be wp_. See the correct table prefix on the left panel of phpMyAdmin, and update the SQL query.

Click Go. The completion message is displayed with the change rows. The number of columns varies from one WordPress site to another.
— The last thing you need to do is confirm the changes. Open the wp_options table and check the option_value of siteurl and home. A new URL will appear.
If you get error messages and the query doesn’t work, check your code for syntax errors and make sure you’re using prefixes correctly. If the error persists, contact hosting support for more information.

Conclusion:

We have learned how to change WordPress URL in MySQL database using phpMyAdmin.

As you can see, all the steps above are very simple. All you have to do is choose the right database and then enter a few lines of code.

I hope this tutorial can give you clear instructions on how to change WordPress URL in MySQL database. If you have any questions, please leave them below!

Leave a Comment