wesley tanaka

Drop all tables in a MySQL Database

‹ Fedora 8 sopcast rpm | God as an entity beyond human comprehension ›
()

echo DROP TABLE `echo 'SHOW TABLES;' | mysql -u USER -p DATABASE | tail -n +2 | sed -e 's/$/,/'` | sed -e 's/,$/;/'

will output the necessary DROP TABLE command. If you have a my.cnf file (in the current directory) you can run the DROP at the same time with:

echo DROP TABLE `echo 'SHOW TABLES;' | mysql --defaults-file=my.cnf | tail -n +2 | sed -e 's/$/,/'` | sed -e 's/,$/;/' | mysql --defaults-file=my.cnf

Suggested Links

Syndicate content