Skip to content

Instantly share code, notes, and snippets.

@sarahmonster
Last active December 19, 2015 03:19
Show Gist options
  • Save sarahmonster/5889465 to your computer and use it in GitHub Desktop.
Save sarahmonster/5889465 to your computer and use it in GitHub Desktop.
A series of files to include in your git directory in order to automate WordpPress database syncs.
USE DBNAME_LOCAL;
UPDATE wp_EXT_options SET option_value="http://LOCALURL:8888" WHERE option_name="siteurl";
UPDATE wp_EXT_options SET option_value="http://LOCALURL:8888" WHERE option_name="home";
USE DBNAME_REMOTE;
UPDATE wp_EXT_options SET option_value="http://REMOTEURL.com" WHERE option_name="siteurl";
UPDATE wp_EXT_options SET option_value="http://REMOTEURL.com" WHERE option_name="home";
git pull https://REMOTE-REPOSITORY-URL.git
cd db
mysql -uUSERNAME -pPASSWORD DBNAME < db_sync.sql
mysql -uUSERNAME -pPASSWORD DBNAME < db_local.sql
git pull https://REMOTE-REPOSITORY-URL.git
cd db
mysql -hREMOTEHOSTNAME -uUSERNAME -pPASSWORD DBNAME < db_sync.sql
mysql -hREMOTEHOSTNAME -uUSERNAME -pPASSWORD DBNAME < db_remote.sql
mysqldump -uUSERNAME -pPASSWORD DBNAME > db/db_sync.sql
# If using MAMP and getting a socket error
# mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect
# Specify the socket in the mysqldump command by using the line below instead
#
# mysqldump --socket=/Applications/MAMP/tmp/mysql/mysql.sock -uUSERNAME -pPASSWORD DBNAME > db/db_sync.sql
mysqldump -hREMOTEHOSTNAME -uUSERNAME -pPASSWORD DBNAME > db/db_sync.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment