What SQL Query to do a simple find and replace

The table where your URL is saved is wp_options. You should do an update on the columns that use the URL for your site:

UPDATE TABLE wp_options SET option_value = "new domain" WHERE option_name = "siteurl"
UPDATE TABLE wp_options SET option_value = "new domain" WHERE option_name = "home"

I might be missing some value, but whenever you do this find/replace process again, you can notice the values and tables that should be updated and add them to this script.

WordPress Codex has a nice guide on how to change a site URL, maybe that’s even handier for you: Changing the Site URL

Leave a Comment