Skip to content

Instantly share code, notes, and snippets.

@mattmcgiv
Created March 13, 2015 16:41
Show Gist options
  • Select an option

  • Save mattmcgiv/a31b08517f3007cf05ee to your computer and use it in GitHub Desktop.

Select an option

Save mattmcgiv/a31b08517f3007cf05ee to your computer and use it in GitHub Desktop.
Generates SQL for replacing URLs in a WordPress database
#PURPOSE to easily generate SQL required to update a WP db to a new URL
#USAGE ./wp-db.bash http://source.com http://destination.com
echo "UPDATE wp_options SET option_value = REPLACE(option_value, '$1', '$2');"
echo "UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '$1', '$2');"
echo "UPDATE wp_posts SET guid = REPLACE(guid, '$1', '$2');"
echo "UPDATE wp_posts SET post_content = REPLACE(post_content, '$1', '$2');"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment