MySQL commands for replace domains and server paths

Useful MySQL commands for replacing domain URL and file path.

UPDATE wp_options SET option_value = replace(option_value, 'http://www.awesome.org','http://www.awesome.dev/cwsa.org');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.awesome.org','http://www.awesome.dev/cwsa.org');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.awesome.org', 'http://www.awesome.dev/cwsa.org'), guid = replace(guid, 'http://www.awesome.org','http://www.awesome.dev/cwsa.org');


UPDATE wp_options SET option_value = replace(option_value, '/public_html/awesome','/var/www/awesome');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'/public_html/awesome','/var/www/awesome');
UPDATE wp_posts SET post_content = replace(post_content, '/public_html/awesome','/var/www/awesome'), guid = replace(guid, '/public_html/awesome','/var/www/awesome');

Leave a Reply

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