Skip to content

Instantly share code, notes, and snippets.

@mt9304
Created January 27, 2019 08:38
Show Gist options
  • Save mt9304/b7e2f596700f5148981eadd1caa4ad73 to your computer and use it in GitHub Desktop.
Save mt9304/b7e2f596700f5148981eadd1caa4ad73 to your computer and use it in GitHub Desktop.
#This scripts creates a dump file from your local MySQL database
#Then changes the siteurl and home columns in the wp_potions table to your Heroku website's url
#Then restores your ClearDB cloud database (Heroku, Wordpress) with this .sql file
#To get host, run herok config --app appname to get the part that looks like us-fewe-wood-south-20.cleardb.net
#Rest can be found in Heroku > app > cleardb > database > stem information
mysqldump -u root -pCHANGEME databasename > appname-$(date +%F)-local-to-cleardb.sql
sed -i -e "s/utf8mb4_unicode_520_ci/utf8mb4_unicode_ci/g" appname-$(date +%F)-local-to-cleardb.sql
sed -i -e "s/'siteurl','https:\/\/localhost'/'siteurl','http:\/\/yourappname.herokuapp.com\/'/g" appname-$(date +%F)-local-to-cleardb.sql
sed -i -e "s/'home','https:\/\/localhost'/'home','http:\/\/yourappname.herokuapp.com\/'/g" appname-$(date +%F)-local-to-cleardb.sql
mysql --host=changeme --user=changeme --password=changeme --reconnect heroku_changeme < appname-$(date +%F)-local-to-cleardb.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment