Posted By

errkk on 10/12/10


Tagged

sql wordpress update wpoptions


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

luglio7


Move WordPress to another host


 / Published in: MySQL
 

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.

  1. # Dev to Production
  2.  
  3. SET @uri_from = 'www.devurl.local';
  4. SET @uri_to = 'www.liveurl.net';
  5.  
  6. UPDATE wp_options SET `option_value` = REPLACE(`option_value`, @uri_from, @uri_to)
  7. WHERE `option_value` LIKE CONCAT( "%", @uri_from, "%" );
  8.  
  9. UPDATE wp_posts SET `guid` = REPLACE(`guid`, @uri_from, @uri_to);
  10.  
  11. UPDATE wp_posts SET `post_content` = REPLACE(`post_content`, @uri_from, @uri_to);
  12.  
  13. UPDATE wp_postmeta SET `meta_value` = REPLACE(`meta_value`, @uri_from, @uri_to);

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: luglio7 on October 12, 2010

yeah

You need to login to post a comment.