Dropping all tables in a MySQL database.

I use this when I need to clear out a database but don’t actually want to drop the database itself. That is, I’m too lazy to recreate it and set up grants.

mysqldump -u<USER> -p<PASS> --add-drop-table --no-data <DATABASE> | grep ^DROP | mysql -u<USER> -p<PASS> <DATABASE>
This entry was posted in Code, Databases, Linux, MySQL. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *