Changing URLs in WordPress MySQL Database

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

This is a very common task when developing WordPress sites and there are loads of sites that show this query.

The problem is, I suffer from some kind of Google search blindness and it always takes a few tries to find the right page. Much easier to put it on my own site.

One Reply to “Changing URLs in WordPress MySQL Database”

Leave a Reply

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