[wp-hackers] siteurl and home should not be in the mysql database

Paul Menard codehooligans at codehooligans.com
Fri Jun 15 13:38:34 GMT 2007


G,

Just curious if you can execute a SQL command. Assuming yes since you  
seem to be dumping the DB and importing it. If so why not just run  
the SQL replace command to update the two wp_options fields. I run  
something similar. I develop the WP site and enter some of the dummy  
content on my laptop. I then dump the DB and push everything to a  
live server for client QA. So all references in the wp_options (both  
of them) and the guid and post_content need to be updated with the  
live URL.

I generally just add the lines to be executed on the live server that  
loads the DB dump. And I agree and question why WP needs to store the  
full URL instead of building it dynamic when needed. Seems  that  
storing the relative URL path and appending the host part would make  
this easier. At least for the wp_posts items anyway.

[string_to_find] is something like 'http://local.www.mysiite.com'
[string_to_replace] is something like 'http://www.mysite.com'

UPDATE wp_options SET option_value = replace(option_value,  
'[string_to_find]','[string_to_replace]') WHERE option_name='siteurl';
UPDATE wp_options SET option_value = replace(option_value,  
'[string_to_find]','[string_to_replace]') WHERE option_name='home';

UPDATE wp_posts SET guid = replace(guid,  
'[string_to_find]','[string_to_replace]');
UPDATE wp_posts SET post_content = replace(post_content,  
'[string_to_find]','[string_to_replace]');

P



More information about the wp-hackers mailing list