Skip to content

Instantly share code, notes, and snippets.

@gusreyes01
Created September 28, 2018 02:50
Show Gist options
  • Save gusreyes01/d5c94e2ca23ada27161ba0a364f3a9f7 to your computer and use it in GitHub Desktop.
Save gusreyes01/d5c94e2ca23ada27161ba0a364f3a9f7 to your computer and use it in GitHub Desktop.
# This script will truncate all tables from the command line
# Don't forget to turn foreign keys back on when you're done
mysql -u root --password=PASSWORD -Nse 'show tables' DATABASE | while read table; do mysql -u root --password=PASSWORD -e "SET FOREIGN_KEY_CHECKS=0;truncate table $table" DATABASE;done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment