Skip to content

Instantly share code, notes, and snippets.

@matiskay
Last active December 17, 2015 15:19
Show Gist options
  • Save matiskay/5631116 to your computer and use it in GitHub Desktop.
Save matiskay/5631116 to your computer and use it in GitHub Desktop.
#! /bin/bash
OLD_URL=''
NEW_URL=''
PREFIX='wp_' # Default prefix.
echo "UPDATE ${PREFIX}_options SET option_value = replace(option_value, '$OLD_URL', '$NEW_URL') WHERE option_name = 'home' OR option_name = 'siteurl';"
echo "UPDATE ${PREFIX}_posts SET guid = REPLACE (guid, '$OLD_URL', '$NEW_URL');"
echo "UPDATE ${PREFIX}_posts SET post_content = REPLACE (post_content, '$OLD_URL', '$NEW_URL');"
echo "UPDATE ${PREFIX}_postmeta SET meta_value = REPLACE (meta_value, '$OLD_URL', '$NEW_URL');"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment