Sometimes you need to remove all the tables in a database. For example, when you are installing or testing a web application. There are GUI tools that can help but we are going to use the command line.
This is a two step process.
First we use mysqldump and grep to generate an sql file containing the tables to drop. Change ‘MYDB’ to the name of the database to drop tables from.
mysqldump --add-drop-table --no-data -u root -p MYDB | grep 'DROP TABLE' > drop_tables.sql
Next use mysql CLI to execute the sql file. Change ‘MYDB’ to the name of the database to drop tables from.
mysql -u root -p MYDB < drop_tables.sql
Thats it. Straight forward and simple.