Here’s an easy way to clear out a Mysql database of all of its tables.
Using mysqldump
user=USER ; pass=PASS ; host=localhost ; database=DATABASE ;\
mysqldump -u${user} -p${pass} -h ${host} --add-drop-table --no-data ${database} \
| grep ^DROP \
| mysql -u${user} -p${pass} -h ${host} ${database}
It works by getting the dump of the database, looking for the DROP
statements, and then dropping those tables.
- source: lowendtalk.com
Using an SQL command/pattern
You can also use LIKE to drop all the tables that match a pattern:
Login to the database.
mysql -u [USER] -h [Host] [Database]
Then once logged into the database:
DROP TABLE LIKE '%pattern%'
- source: mysqltutorial.org