Skip to content

Instantly share code, notes, and snippets.

@rpavez
Created January 7, 2019 18:37
Show Gist options
  • Save rpavez/16fc7099b341eac72aa6414173cac094 to your computer and use it in GitHub Desktop.
Save rpavez/16fc7099b341eac72aa6414173cac094 to your computer and use it in GitHub Desktop.
Remove
#!/bin/sh
export DB_NAME=<db_name>
export MYSQL_PASSWORD=<pass>
mysql -Nse 'show tables' $DB_NAME -u root -p$MYSQL_PASSWORD | while read table; do mysql -e "SET FOREIGN_KEY_CHECKS=0; truncate table $table;SET FOREIGN_KEY_CHECKS=1;" $DB_NAME -u root -p$MYSQL_PASSWORD ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment