Change Wordpress URL in Database (MySQL)

From ETCwiki
Revision as of 15:45, 20 February 2016 by Ddxfish (talk | contribs) (Created page with "This code is to search and replace an old URL with a new URL inside your Wordpress SQL database. It would be easy to paste this code into phpmyadmin in the SQL tab to run all...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This code is to search and replace an old URL with a new URL inside your Wordpress SQL database. It would be easy to paste this code into phpmyadmin in the SQL tab to run all of these. Make sure you backup your database before you do anything!


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

External Links