WordPress URL Replacement Queries for MySQL

Replace WordPress development URLs with live URLs

We often get the question about how to update URLs in WordPress after migrating from development to a live server. We feel it’s time to share a secret that will make your life a lot easier¬†than updating each and every page, post and/or custom post in your site. The answer are these WordPress URL replacement queries for MySQL.

UPDATE wp_posts SET guid = REPLACE(guid, 'ENTER DEV BASE URL', 'ENTER LIVE BASE URL');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'ENTER DEV BASE URL', 'ENTER LIVE BASE URL');
UPDATE wp_options SET option_value = REPLACE(option_value, 'ENTER DEV BASE URL', 'ENTER LIVE BASE URL');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'ENTER DEV BASE URL', 'ENTER LIVE BASE URL');

Simply replace the ‘ENTER DEV BASE URL’ with the base url or your development server, for example: https://localhost/summus.io. Then, replace ‘ENTER LIVE BASE URL’ with the base url to your live server, for example: https://summus.io.