Migrate WordPress database

WordPress migrate database from localhost to production

UPDATE wp_options SET option_value = replace(option_value, 'http://localhost/mysite', 
'http://www.mysite.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://localhost/mysite',
'http://www.mysite.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://localhost/mysite', 
'http://www.mysite.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://localhost/mysite',
'http://www.mysite.com');

WordPress migrate database from site to localhost

UPDATE wp_options SET option_value = replace(option_value, 'http://www.mysite.com', 
'http://localhost/mysite') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.mysite.com',
'http://localhost/mysite');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.mysite.com', 
'http://localhost/mysite');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.mysite.com',
'http://localhost/mysite');

Leave a Reply