Biggest deals of the year. 30-day money-back guarantee. Limited time deals. 24/7 support. Don't miss out

How to change WordPress URL in database using phpMyAdmin

To change your WordPress URL in the database, open phpMyAdmin, select your WordPress database, and update the home and siteurl values in the wp_options table. These settings control your site’s public address and WordPress installation URL.

Editing the database directly is useful when you can’t access wp-admin, need to correct an incorrect site URL, or have changed your domain during a migration. For an HTTP-to-HTTPS change, you may also need to update these values.

Before making changes, back up your database. Updating home and siteurl changes WordPress’s main URL settings, but it doesn’t automatically update links stored elsewhere in your site’s content or plugin settings.

1. Find your WordPress database

Before changing your WordPress URL, identify the WordPress database connected to your website. This ensures you’re editing the correct installation, especially if your hosting account contains multiple WordPress websites or databases.

You can find your WordPress database name in the wp-config.php file or through your hosting control panel.

If you’re using Hostinger, Open Hostinger dashboard and navigate to WordPress → Overview. The database name is listed in the Database section.

You can also find the database name in the wp-config.php file. Open File Manager from Hostinger dashboard, locate wp-config.php in your root directory, and search for DB_NAME. The value next for parameter is your database name.

wp-config file, database username highlighted

2. Back up your WordPress database

Before changing your WordPress URL, back up your database so you can restore the original settings if something goes wrong.

To create a backup using phpMyAdmin:

  1. Open phpMyAdmin from your hosting control panel.
  2. Select your WordPress database from the left sidebar.
  3. Click the Export tab.
  4. Choose Quick as the export method and SQL as the format.
  5. Click Export to download the backup file.

Store the downloaded SQL file somewhere safe. If the URL change causes issues, you can restore the previous database using this backup.

If you’re using Hostinger, you can also back up your WordPress website using the available backup tools in hPanel.

3. Change your WordPress URL in phpMyAdmin

Once you’ve identified and backed up your WordPress database, you can change your website’s URL using phpMyAdmin. You can manually edit the home and siteurl values to change your website’s main address or run SQL queries to update those settings and replace old URLs in post content.

Method 1. Change the WordPress URL manually

This method is useful when you need to correct your website’s address, restore access to wp-admin, or update the primary URL after switching domains.

  1. Open phpMyAdmin and select your WordPress database from the left sidebar.
  2. Find the wp_options table and click Browse. The table prefix may differ from wp_ depending on your WordPress installation.
  3. Locate the row where option_name is siteurl and click Edit.
  4. Change its option_value to your new WordPress installation URL, such as https://example.com, then click Go to save.
  5. Find the row where option_name is home and click Edit.
  6. Update its option_value to your website’s new public URL and click Go to save.

For most WordPress websites, home and siteurl contain the same URL. However, they can differ if WordPress is installed in a separate directory.

Use the full URL, including https:// when your website has a working SSL certificate, and don’t add a trailing slash.

Updating these values changes your WordPress website’s primary URL settings, but it doesn’t automatically update old links stored in posts, images, or plugin settings.

Method 2. Change WordPress URLs using SQL queries

If you’re migrating your WordPress website to a new domain, you can use SQL queries to change the main site URLs and replace references to the old domain in post content.

  1. Go to phpMyAdmin via your website’s control panel.
  2. The left panel lists all of your databases. Select the one connected to your WordPress site and head to the SQL tab.
phpMyAdmin run SQL query/queries on database
  1. 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');

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

Important

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

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

    Next step: Check your website for redirect issues

    After changing your WordPress URL in the database, check that your website loads correctly and visitors can access its pages without unexpected redirects.

    If your website still redirects to the previous address, review your WordPress settings, caching configuration, and existing redirect rules. You may need to manage your WordPress redirects to make sure visitors reach the correct URLs.

    Also, check that your WordPress dashboard, internal links, and images work as expected. If you encounter problems, restore the previous URL settings or your database backup.

    This article is a localized version of How to change WordPress URL in database using phpMyAdmin, originally published in English.

    All of the tutorial content on this website is subject to Hostinger's rigorous editorial standards and values.

    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.

    Trusted by 4+ million website owners worldwide

    See our 73,326 reviews on Trustpilot