MySQL for Updating WordPress Post URLs

Sometimes you’ll need to update post and page urls when going from a development environment to production, or more simply when going from one domain to the next. If you have many (10s to 100s), and you will have that if the WP snapshots have been run, then you’ll want to update them all easily. You can do this with MySQL:

UPDATE wp_posts SET guid = REPLACE(guid,"dev.site.com","www.site.com");
UPDATE wp_posts SET post_content = REPLACE(post_content,"dev.site.com","www.site.com");
UPDATE wp_options SET option_value = REPLACE(option_value,"dev.site.com","www.site.com");
UPDATE wp_links SET link_url = REPLACE(link_url,"dev.site.com","www.site.com");
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value,"dev.site.com","www.site.com");

That’s it. You can update your WordPress post and page url values with just a little html.

Here’s a resource from WordPress to help with a WordPress move:

http://codex.wordpress.org/Changing_The_Site_URL

Post written by Ed Reckers

Founder and lead web development consultant at Red Bridge Internet : San Francisco WordPress Developers and Consultants.

2 Responses to “MySQL for Updating WordPress Post URLs”

  1. subha

    thank you

Leave a Reply