Skip to main content

How-to: Drop all tables from a mysql database

Posted in

Much easier than have to drop a database, recreate it, and then grant privileges again.

mysqldump -u <username> -p <password> --add-drop-table --no-data <database> | grep ^DROP | mysql -u <username> -p <password <database>

Trackback URL for this post:

http://www.jbip.net/trackback/41

Privileges are preserved

You do not have to grant privileges again if you drop/recreate database in MySQL (at least in 5, do not remember in 4, but pretty sure - the same).

Nice code snippet though.