Wordpress - How to replace the domain name in a Wordpress database?

Codex has decent guide - Changing Site URL.

Basically there are several places there URL matter or not so much (I may be missing some):

  • home and siteurl options that control where WP thinks site is;
  • post GUIDs, these look like links but really they aren't - only identifiers. I am not absolutely sure they are irrelevant, but I had URLs change on test stack a lot and never bothered to update these.
  • links in post bodies;
  • possibly links in plugin settings.

The data you're looking at is not JSON formatted. JSON doesn't (normally) store value types and lengths like that. What you're looking at is SERIALIZED data. A google search for "mysql replace serialized" yields this page, which might help: http://davidcoveney.com/mysql-database-search-replace-with-serialized-php/


As Rarst said above there's only two settings in the database that NEEDS changing. After importing the database I log into PHPMyAdmin and edit the database direct.

I use a development server on my PC all the time to import datafeeds and they have the URL attached to the Posts along the lines of http://localhost/testsite/post-name/ and it's never caused a problem.

I used to use an SQL search and replace until I realised it didn't matter. I've migrated a few sites from one domain to another and where I've had absolute URLs in the content I'll use the SQL search and replace option.

update wp_posts set post_content = replace(post_content,'http://www.olddomain/','http://www.newdomain/');

David