Created
March 2, 2015 18:54
-
-
Save mitchelldmiller/83eb4416f68d943b028c to your computer and use it in GitHub Desktop.
Import production WordPress database to localhost without plugin update error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# import_wordpress_db_to_localhost.sh | |
# | |
# Easy to use to with multiple sites. | |
# Try: | |
# alias import_blog='import_wordpress_db_to_localhost.sh DB SQL user password' | |
# | |
if [ ! -z $1 ] && [ ! -z $2 ] && [ ! -z $3 ] && [ ! -z $4 ] && [ -f $2 ]; then | |
echo "Updating $1 with $2 and local settings" | |
# import database | |
mysql -u$3 -p$4 -AD $1 < $2 | |
# clear plugins | |
mysql -u$3 -p$4 -AD $1 -e "update wp_options set option_value = 'a:0:{}' where option_name = 'active_plugins';" | |
# add "LOCAL : " to site name | |
mysql -u$3 -p$4 -AD $1 -e "update wp_options set option_value = concat('LOCAL: ', option_value) where option_name = 'blogname';" | |
# make blog private | |
mysql -u$3 -p$4 -AD $1 -e "update wp_options set option_value = 0 where option_name = 'blog_public';" | |
else | |
echo "Usage: import [DB] [SQL] [USER] [PASSWORD]"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment