Skip to content

Instantly share code, notes, and snippets.

@calebbrewer
Last active January 7, 2019 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save calebbrewer/5651654 to your computer and use it in GitHub Desktop.
Save calebbrewer/5651654 to your computer and use it in GitHub Desktop.
This is for putting a MySQL DB under Git.
#Pre-commit hook
#!/bin/sh
mysqldump -uuser -ppassword --skip-extended-insert databaseName > /path/to/your/repo/database.sql
cd /path/to/your/repo
git add [database].sql
#Post-merge hook
#!/bin/sh
mysql -u [mysql user] -p[mysql password] [database] < /path/to/your/repo/[database].sql
#If using wamp on Windows for local dev
#Be sure to check version numbers and db name.
#Dump
C:\wamp\bin\mysql\mysql5.5.24\bin\mysqldump.exe -uroot --skip-extended-insert dbName > c:\example.sql
#Write
C:\wamp\bin\mysql\mysql5.5.24\bin\mysql.exe -uroot dbName < c:\example.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment