Created
October 14, 2012 06:00
-
-
Save thewatts/3887543 to your computer and use it in GitHub Desktop.
Snippets to use with AlfredApp to import your production database into your local database, and then change your production URL values to your local URL values in WordPress.
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
-- This file will be used in the snippet below. | |
-- This is the name of your local database | |
USE local_db | |
-- Replacing all instances of your production URL with your local URL | |
UPDATE wp_options SET option_value = replace(option_value, 'http://sitename.com', 'http://sitename.local') | |
WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wp_posts SET guid = REPLACE (guid, 'http://sitename.com', 'http://sitename.local'); | |
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://sitename.com', 'http://sitename.local'); | |
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://sitename.com','http://sitename.local'); |
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
# Dump Production DB | |
/Applications/MAMP/Library/bin/mysqldump -h host_server_ip -u username -p'password' production_db_name > ~/path/to/production_dump.sql | |
#Import to Local server | |
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot local_db < ~/path/to/production_dump.sql | |
#Change the URL values | |
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot local_db < ~/path/to/db_prod2local_alfredapp.sql | |
echo "BOOM! DB IMPORTED PRODUCTION DATABASE TO LOCAL ENVIRONMENT." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment