Move WordPress to another host

SQL query to update wp_options records that are specific to the host of a WordPress site. Run this query after copying the DB to another server (if this URL is different). Useful for deploying WordPress from a dev server to a live environment.

Wordpress-Hosting

# Dev to Production
SET @uri_from = 'www.devurl.local';
SET @uri_to = 'www.liveurl.net';
UPDATE wp_options SET `option_value` = REPLACE(`option_value`, @uri_from, @uri_to)
WHERE `option_value` LIKE CONCAT( "%", @uri_from, "%" );
UPDATE wp_posts SET `guid` = REPLACE(`guid`, @uri_from, @uri_to);
UPDATE wp_posts SET `post_content` = REPLACE(`post_content`, @uri_from, @uri_to);
UPDATE wp_postmeta SET `meta_value` = REPLACE(`meta_value`, @uri_from, @uri_to);
Advertisements

One thought on “Move WordPress to another host

  1. That’s really useful. Thanks.
    However, if folks don’t want to move the site themselves, I’m offering a ‘move WordPress to a new hosting provider service’ over at migrately.com – come and check us out!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s