How to Change WordPress URLs in MySQL Database Using phpMyAdmin

How to Change WordPress URLs in MySQL Database Using phpMyAdmin

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!

Upgrade to WordPress Hosting with Hostinger today! With a guaranteed 99.99% uptime!

Get Your Discount Here

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 hPanel and open File Manager.
  2. Select the domain name, then click Go to File Manager.
    This image shows you how to go to the File Manager in hPanel
  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 is u923246418_gagap.The DB_NAME parameter that contains the name of your MySQL database

2. Changing WordPress URLs in MySQL Database

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

  1. Go to phpMyAdmin via your website control panel.
  2. The left panel list all of your databases. Select the one connected to your WordPress site and head to the SQL tab.Selecting the correct database in phpMyAdmin
  3. Enter the following SQL query:

    UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';UPDATE wp_posts SET guid = replace(guid, '','');UPDATE wp_posts SET post_content = replace(post_content, '', '');
    UPDATE wp_postmeta SET meta_value = replace(meta_value,'','');

    Replace with your current WordPress address and with your new WordPress address.

    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.
    This image shows that you have successfully changed your WordPress URLs
  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.
    The new URLs in wp_options table

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.


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!

The Author


Domantas G. / @domantas

Domantas leads the content and SEO teams forward with fresh ideas and out of the box approaches. Armed with extensive SEO and marketing knowledge, he aims to spread the word of Hostinger to every corner of the world. During his free time, Domantas likes to hone his web development skills and travel to exotic places.


Pat Reply

April 04 2018

Hi, I followed your instructions but it seems my new site still redirects to the old URL. I've checked the wp_options as you said and it's all pointing to the new. Very weird. Pat


    Domantas G.

    Replied on April 28 2018

    Hey Pat, Do you have any kind of caching plugin installed? if so, try to clear cache or disable the plugin


Apollos Reply

October 25 2019

This worked wonderfully well for me. Thank you!


Tawsif Shah Mostafa Reply

January 01 2020

helpful post for a developer, thanks!

Author Reply

February 08 2020

thanks for share this article


Joe Reply

June 20 2020

Excellent and well documented solution! Thanks


Christine Yeary Reply

June 26 2020

What if we don't have any table of wp_options ?


    Tomislav T.

    Replied on July 07 2020

    Hey Christine! :) Perhaps you can check if you are using a custom prefix for the tables? In wp-config.php you can change the prefix of the tables, so if you set it to for example blog, your table would be blog_options. Additionally, make sure to select "Show ALL" instead of "Show 25" which is the default value for the shown tables in phpMyAdmin :)

Leave a reply




This site uses Akismet to reduce spam. Learn how your comment data is processed.

Become a part of Hostinger now!

More in WordPress