How to Change WordPress URLs in MySQL Database Using phpMyAdmin

WordPress uses MySQL database to store all its data: posts, pages, profiles, configuration. If you moved your WordPress website to a different folder or your domain name has changed, it is necessary to change WordPress URLs in various MySQL database tables.

What you’ll need

Before you begin this guide you’ll need the following:

  • Access to the control panel of your hosting account.
  • Basic understanding of phpMyAdmin.

Step 1 — Determining Name of WordPress MySQL Database

You can skip this step if you have only one MySQL database. However, if you have more than one and not sure which database is connected to WordPress, you need to determine the name of MySQL database. WordPress stores MySQL database name and credentials in wp-config.php file. You can find wp-config.php in your root WordPress file directory. Use File Manger of FTP client to access this file.

Checking wp-config.php file

Open wp-config.php file and search for 'DB_NAME'.

Determining MySQL database name

In this case name of our MySQL database is ptsk6_wp649.

Step 2 — Entering phpMyAdmin

You can find phpMyAdmin under databases section in your control panel.

Entering phpMyAdmin from control panel

Step 3 — Selecting Appropriate Database.

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

Selecting MySQL database in phpMyAdmin

Step 4 – Formatting SQL Query

Press 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. For example if your current WordPress address is oldurl.com, it will be changed to newurl.com.

IMPORTANT! Do not forget to replace oldurl.com with your current WordPress address and newurl.com with your new WordPress address.

Formating SQL Query

IMPORTANT! Sometimes table prefix can be different than wp_. If you get error messages saying that tables wp_options, wp_posts, wp_posts and wp_postmeta cannot be found, check table prefix and update SQL query code. You can see table prefix on the left side of phpMyAdmin, under your WordPress database:

Checking table prefix

In this example 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 it, press GO button which is located on the bottom right.

Running SQL Query

Step 6 – Verifying The Successful Change of URLs

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

Green Success Message

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

In order to verify changes open wp_options table and check your home and siteurl values. You should see new WordPress urls from the SQL query. In this example WordPress urls were changed to newurl.com

Checking wp_options table

If you get errors and query is not executing, check your code for syntax errors and make sure you are using the correct table prefix. If you still get any errors, simply contact support staff of hosting for assistance.


You just learned how to change WordPress URLs in MySQL database using phpMyAdmin. If you have not yet moved WordPress to a different folder, you can do so by following this tutorial.

About the author

Domantas G.

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.


Click here to post a comment

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

  • 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.

Get Exclusive Content

Join thousands of webmasters who get our free newsletter with tips on how to drive more traffic and revenue to their websites!

Please wait...

Thank you for sign up!