What do you mean here by database cleanup-
- You want to drop all tables from DB and want DB blank.
- Or you want to purge all data but need all tables intact in DB.
In first case better option is just drop database and re-create it.
OR if due to any specific reason you don't want to drop database (as in this way you will loose all triggers/views etc.) then first get tables for drop by show tables command and prepare "drop table table_name;" script in excel or by below command and execute through phpmyadmin.
SELECT CONCAT("drop table ",table_schema,".",table_name,";") FROM information_schema.TABLES WHERE table_type='BASE TABLE' AND table_schema='my_db';
In Second Case if you want to purge data only then you can prepare truncate script by below command and then execute it by phpmyadmin-
SELECT CONCAT("truncate table ",table_schema,".",table_name,";") FROM information_schema.TABLES WHERE table_type='BASE TABLE' AND table_schema='my_db';
Note: execute set foreign_key_checks=0;
before executing drop or truncate commands and set foreign_key_checks=1;
after execution to avoid foreign key related issues.
You can execute below command on server console.
mysql -uroot -p<pass> -Nse 'show tables' database1 | while read table; do mysql -uroot -p<pass> database1 -e "drop table $table"; done
OR
mysql -uroot -p<pass> -Nse 'show tables' database1 | while read table; do mysql -uroot -p<pass> database1 -e "truncate table $table"; done