How to empty a mysql database

This morning I was doing some tests and I found myself having to use a web-based mysql tool called phpmyadmin to delete all the tables in a mysql database.

Since I was to do it several times, I decided to use the command line interface program mysql. I was kinda surprise that I didn’t find any single command to drop all the tables, anyway deleting all the tables can be done by issuing the following command:

sh$ mysql -u username -p -e “drop database dbname; create database dbname;”

You will need to specify a username with drop/create privileges for the dbname database. It will then prompt for the user’s password when you hit enter on the command line.