How to drop all table in MySQL? How to drop all table in MySQL? mysql mysql

How to drop all table in MySQL?


You were talking about doing this in phpMyAdmin.

I just had to do this and I'm not sure what version you are using but in the version I have if you scroll to the bottom of the table list you can click "Check All" and then in the drop down next to it that has "With Selected:" you can select "Drop" and it empties all the tables.


mysqldump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data [DATABASE] | grep ^DROP | mysql -u[USERNAME] -p[PASSWORD] [DATABASE]

Here there are more methods to drop all tables without dropping the database.


You can also generate a sql file from the information_schema database:

Select concat('DROP TABLE database_name.', table_name,';') from information_schema.TABLES where table_schema='database_name';

This will give an output like:

DROP TABLE database_name.table1;DROP TABLE database_name.table2;[...]DROP TABLE database_name.tableN;