October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Change WordPress URLs in the MySQL Database

A practical, safety-first guide to changing WordPress URLs in MySQL, including the siteurl and home rows, WP-CLI search-replace, SQL limitations, configuration constants, backups, and troubleshooting.
Length9 min Posted Quest giverVGSources Team

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To change a WordPress address safely, update the siteurl and home rows in the site’s options table, then replace the old address wherever it appears in content. The rows change where WordPress loads and what visitors see; they do not automatically rewrite links in posts, media, widgets, theme settings, or page-builder data. Use a backup, preview any bulk replacement with WP-CLI’s --dry-run, and check wp-config.php if the database values appear to have no effect.

What the two WordPress URL values control

WordPress stores two primary addresses in the options table. The table is commonly named wp_options, but wp_ is only the default prefix; use the prefix configured for your installation.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Option Purpose What changing it affects
siteurl The address where the WordPress core installation is located. Core-generated paths, administrative URLs, and the location WordPress uses for its own files.
home The public address visitors use to reach the site. Front-end links and the canonical site address presented to visitors.

For a conventional installation, both values are often the same, such as https://old.example.com. They can legitimately differ when WordPress is installed in a separate directory from the public site, so do not overwrite one with the other without confirming the intended architecture.

Why changing only the options rows is not a complete migration

WordPress and its extensions can store the old address in post content, excerpts, navigation data, attachment metadata, widget settings, theme options, custom fields, and page-builder layouts. Updating siteurl and home changes the two control values but leaves those stored references untouched. Visitors may therefore see broken images, old-domain links, mixed content, or embeds that still point to the previous address.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

A complete change has two distinct operations:

  • Set the two address options to the new URL.
  • Search the relevant tables for the old URL and replace it with the new URL.

Do not treat a successful update of the options table as proof that every stored link has been changed.

Prepare before editing MySQL

Make a restorable backup

Export the database before changing anything. Keep the export somewhere separate from the live database and know how you would restore it with your database tool or hosting control panel. A URL migration can affect thousands of values, so a backup is the practical recovery point if a replacement is too broad or a serialized value becomes damaged.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Record the current values

With WP-CLI available, record both values before editing:

wp option get siteurl
wp option get home

If you are using only a database client, read the rows from the options table and note the exact old URL, including its protocol and any path. Also confirm the table prefix in wp-config.php; a site using a prefix such as abc_ stores its options in abc_options, not wp_options.

Confirm the target address

Write down the complete new address and decide whether the change is a domain change, a protocol change, a directory change, or a combination. Search-and-replace is literal: replacing https://old.example.com does not replace http://old.example.com or an old URL that includes a path unless those forms are handled separately.

Choose a method

Method Scope Serialized-data safety Access required Best use
WP-CLI option update plus search-replace Two options and then registered WordPress tables. WP-CLI recalculates serialized string lengths. Shell access and WP-CLI. The preferred approach for a normal migration.
SQL update of home and siteurl Only the two rows. Safe for these plain URL values, but it does not migrate other stored links. A MySQL client or database panel. Emergency recovery or a deliberate options-only change.
Raw SQL replacement across every table Potentially the whole database. Unsafe for PHP serialized values because byte-length prefixes are not recalculated. A database client. Do not use for a WordPress-wide URL migration.
WP_HOME and WP_SITEURL constants Overrides the database values at runtime. Does not rewrite stored content. File access to wp-config.php. Temporary troubleshooting or intentionally pinning an address.

Preferred procedure with WP-CLI

1. Check the installation and values

Run the commands from the WordPress directory, or supply the appropriate path according to your WP-CLI setup:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
wp option get siteurl
wp option get home

Confirm that the output matches the old address you intend to replace. If the values are already the new address, the remaining work is likely a content search-and-replace rather than an options update.

2. Set the two address options

Use wp option update to write the new values:

wp option update siteurl 'https://new.example.com'
wp option update home 'https://new.example.com'

Use the real public URL for home and the real core location for siteurl when those locations differ. These commands update the database; they do not alter URLs embedded elsewhere.

3. Preview the content replacement

Before writing a bulk change, run a dry run using the old and new strings:

wp search-replace 'https://old.example.com' 'https://new.example.com' --skip-columns=guid --dry-run

The dry run reports the rows and values that would change without saving them. Review the table and column counts. A result that is unexpectedly large can indicate that the old string is too short or too broad; stop and refine the exact old URL rather than accepting an uncontrolled replacement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The example uses --skip-columns=guid, as shown in the WP-CLI migration guidance. Keep that option unless you have a specific, documented reason to handle that column differently.

4. Run the live replacement

When the preview is reasonable, run the same command without --dry-run:

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
wp search-replace 'https://old.example.com' 'https://new.example.com' --skip-columns=guid

WP-CLI’s search-and-replace routine is designed for WordPress data and recalculates the byte lengths used by PHP serialized strings. That matters for widget settings, theme options, and builder layouts, where a naïve text replacement can make the stored value unreadable.

5. Decide whether --all-tables is necessary

By default, the command targets tables registered to WordPress’s database object. Use --all-tables only when the old URL also exists in tables outside that registered set and you have verified that those tables should be changed. Extending the scope increases the number of records affected; preview the expanded command with --dry-run first.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

6. Verify the options and application

Read the values again:

wp option get siteurl
wp option get home

Then clear relevant page, object, CDN, and browser caches, open the public site, and test an administrator login. Check representative posts, images, menus, forms, and any page-builder screens that contain saved layouts.

Changing only the two rows with SQL

If WP-CLI is unavailable and you intentionally need to change only the addresses, update the two option rows in the correct prefixed table:

UPDATE wp_options
SET option_value = 'https://new.example.com'
WHERE option_name IN ('siteurl', 'home');

Replace wp_options with the actual options-table name and replace the URL with the exact target address. This query changes the two control values quickly, but it does not search post content, metadata, widgets, theme settings, or other options for the old address.

Use this SQL-only method as a focused repair or as the first part of a larger, carefully planned migration. Do not follow it with a blanket SQL REPLACE() across every column. WordPress stores many values as PHP serialized strings containing byte-length prefixes. Changing the text while leaving those lengths unchanged can break the value, causing missing widgets, damaged theme settings, or unusable builder layouts.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Why a raw SQL find-and-replace is risky

A database-wide expression such as a SQL REPLACE() appears convenient because it can touch many tables at once. It cannot, however, understand PHP serialization. A serialized string records how many bytes the string contains; changing the URL changes that count. Unless the replacement process parses and rewrites the serialized structure, PHP may reject the value or read the remainder incorrectly.

The practical rule is simple: use SQL for the two plain option rows when necessary, and use a WordPress-aware tool for a content-wide replacement. WP-CLI’s search-replace is the option in this workflow that preserves serialized data.

When WP_HOME or WP_SITEURL overrides MySQL

WordPress can define the public and core addresses as constants in wp-config.php:

define( 'WP_HOME', 'https://new.example.com' );
define( 'WP_SITEURL', 'https://new.example.com' );

When these constants are present, they override the corresponding values in wp_options at runtime. The database may show the old URL while the site uses the value from the configuration file. Conversely, changing the database may appear to do nothing because the constants continue to win.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check wp-config.php whenever the front end, login page, or command output conflicts with the values you just edited. If the constants were added only for troubleshooting, remove them after the database contains the intended permanent values; removing the lines allows WordPress to use the stored options again. If the constants are intentionally retained, document that they are the authoritative settings so a later database edit is not mistaken for a failed migration.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Redirect loops and login failures

A mismatch between the database values and configuration constants can produce repeated redirects or prevent the administrator area from loading. Compare all of the following:

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
  • siteurl in the options table.
  • home in the options table.
  • WP_HOME and WP_SITEURL, if defined in wp-config.php.
  • The exact protocol and host being requested in the browser.

Remove or correct conflicting constants, then clear caches and retry the front end and administrator login. Do not keep temporary override settings in place after the address has been stabilized.

Using the RELOCATE constant

WordPress migration documentation also describes a RELOCATE constant that can change the stored siteurl. Treat it as a temporary recovery mechanism, not as a substitute for a planned search-and-replace. The documentation warns that leaving it enabled can be insecure in some configurations. If you use it, remove it immediately after the required correction and then verify the stored values and login behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Post-migration verification checklist

Use a representative, not just a single home-page, test:

  • Open the home page and several older posts.
  • Click navigation menus and internal links.
  • Load images, downloadable files, and embedded media.
  • Open the administrator login and a few dashboard screens.
  • Inspect widgets, theme customizer settings, and builder-created pages.
  • Check forms, feeds, and integrations that store callback or asset URLs.
  • Search the database or application output for the old URL if links still point to it.

If only some links remain old, the options update worked but the content replacement did not cover the table or value where those links are stored. Recheck the dry-run scope and whether the old address appears in another form, such as a different protocol or directory path.

Recovery when something goes wrong

The site redirects to the old address

Read both options and inspect wp-config.php for constants that still specify the old value. Correct the authoritative setting, clear caches, and test again.

Widgets or layouts disappear after a database replacement

Stop making further replacements and restore the database backup. This symptom is consistent with serialized data being altered by a raw SQL replacement. Repeat the migration with WP-CLI’s WordPress-aware command instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The front end works but internal links are mixed

The two options may be correct while stored content still contains the old URL. Run a narrowly targeted WP-CLI dry run for the exact old string, inspect the affected tables, and then execute the live replacement if the scope is appropriate.

The command reports no changes

Confirm that the old URL is spelled exactly as stored, including protocol, host, and path. Also verify that you are running WP-CLI against the intended WordPress installation and that the tables containing the old value are registered. Only add --all-tables after a dry run shows that an external table is genuinely part of the migration.

A repeatable runbook

  1. Export the database and confirm that the backup can be restored.
  2. Record siteurl and home with wp option get, or read them from the correctly prefixed options table.
  3. Check wp-config.php for WP_HOME and WP_SITEURL overrides.
  4. Choose the exact old and new URL strings, including protocol and path.
  5. Use wp option update for the two control values when WP-CLI is available, or use the focused SQL update when only the rows must change.
  6. Preview a content-wide replacement with wp search-replace, --skip-columns=guid, and --dry-run.
  7. Review the reported scope, then run the same command without --dry-run.
  8. Use --all-tables only for verified tables outside WordPress’s registered set.
  9. Flush caches, test the front end and administrator login, and inspect representative content.
  10. Remove temporary constants such as troubleshooting overrides or RELOCATE when they are no longer required.

The durable solution is not merely changing two strings in MySQL. It is aligning the database options, any configuration constants, and every stored content reference while preserving serialized data. Backing up first and previewing the WP-CLI operation gives you a recoverable, auditable path from the old address to the new one.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.