A female engineer works on code in a contemporary office setting, showcasing software development.

SQL Queries to Change WordPress Site Domain

Generate SQL queries to update a WordPress site domain in the database. This tool helps when migrating a site to a new domain or protocol. Always back up your database before executing the generated queries.

Tip: Always create a database backup before running SQL queries. REPLACE() may break serialized data.

Changing the domain of a WordPress website often requires updating URLs directly in the database. This is especially common during site migrations, server changes, or rebranding projects.

This tool helps you generate the necessary SQL queries to change a WordPress site domain quickly and safely, avoiding manual mistakes and saving time.

Why Use SQL Queries to Change a WordPress Domain?

When a WordPress site is moved to a new domain, the old URLs remain stored in multiple database tables. If they are not updated properly, the site may experience:

  • Broken internal links
  • Missing images and assets
  • Mixed content warnings
  • SEO and indexing issues

Using SQL queries allows you to update all relevant URLs at once, directly at the database level.

What This WordPress Migration SQL Tool Does

This generator creates ready-to-use MySQL SQL queries that help you:

  • Update the home and siteurl values
  • Replace old domain URLs in post content and excerpts
  • Update URLs stored in post meta and term meta
  • Adjust attachment GUIDs when required

The tool only generates the queries — it does not execute them automatically — giving you full control over when and where the changes are applied.


Required Information

To generate the SQL queries, you only need to provide:

  • From – the current WordPress site URL (old domain)
  • To – the new WordPress site URL
  • Prefix – the database table prefix used by WordPress (for example, wp_)

Once these values are entered, the tool outputs SQL queries that can be executed in your WordPress database.

How to Change a WordPress Site Domain Using SQL

Follow these steps to update your WordPress domain using SQL queries:

  1. Enter the old site domain.
  2. Enter the new site domain.
  3. Specify the database table prefix.
  4. Generate the SQL queries.
  5. Run the queries in your MySQL database.

This approach is particularly useful when the WordPress admin dashboard is not accessible or when a site fails to load correctly after migration.


Using SQL Queries with WordPress Multisite

The generator also supports WordPress Multisite installations, with a few important considerations:

  • SQL queries must be generated and executed separately for each subsite, using prefixes such as wp_2_, wp_3_, etc.
  • Some multisite tables require manual updates:
    • wp_blogs
    • wp_site
    • wp_sitemeta

These tables store network-level configuration and should be handled carefully when changing domains.


How to Run SQL Queries in WordPress

To apply the generated SQL queries, you need access to your WordPress MySQL database. The most common method is using phpMyAdmin, available through most hosting providers.

Run SQL Queries Using phpMyAdmin

  1. Open phpMyAdmin from your hosting control panel.
  2. Select the WordPress database.
  3. Go to the SQL tab.
  4. Paste the generated SQL queries.
  5. Execute the queries.

After execution, the WordPress site domain stored in the database will be updated.


Important Notes Before Running SQL Queries

Before changing a WordPress site domain using SQL, keep the following best practices in mind:

  • Always create a full database backup
  • Test the queries on a staging environment first
  • Be cautious with serialized data, especially when using advanced plugins

A Practical Tool for WordPress Developers

This SQL generator is built for WordPress developers and advanced users who need a reliable and controlled way to change a WordPress site domain using SQL queries.

Whether you are migrating a site, fixing broken URLs, or preparing a production deployment, this tool helps streamline the process.