/ Published in: Bash
This script removes (DROPS) all tables that start with foo_. Usefull if you had some CMS or application that (ab)uses table prefixing, and want to clean 0ut your database.
NOTE: the data is remove FOREVER! So take good casre: make backups and all the likes. Try on a test-database first!
NOTE: the data is remove FOREVER! So take good casre: make backups and all the likes. Try on a test-database first!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
mysql -u[username] -p[password] -h[host] [databasename] -e "show tables like 'foo_%';" -N | awk '{ print "DROP TABLE " $1 ";" };' | mysql -u[username] -p[password] -h[host] [databasename]