Skip to content

Instantly share code, notes, and snippets.

@micc83
Last active October 20, 2015 13:20
Show Gist options
  • Save micc83/7615f81d035c938e72e5 to your computer and use it in GitHub Desktop.
Save micc83/7615f81d035c938e72e5 to your computer and use it in GitHub Desktop.
Cronjob to drop tables and import dump file to MySql database
#!/bin/bash
mysqldump -u[username] -p[password] \
--add-drop-table --no-data [database] | \
grep -e '^DROP \| FOREIGN_KEY_CHECKS' | \
mysql -u[username] -p[password] [database]
mysql -u[username] -p[password] [database] < [dump_file.sql]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment