MySQL empty database / delete all tables
Q. How do I empty MySQL database? What SQL command needs to be executed in order to delete all (100s) of tables in MySQL database called atomstore?
A. You need to use DROP DATABASE sql command to drops all tables in the database/empty database and deletes the database. Be very careful with this statement! To use DROP DATABASE, you need the DROP privilege on the database
Syntax:
DROP DATABASE {mysql-database-name}
To drop atomstore database, login as root user:
$ mysql -u root -p
Now drop database:
mysql> DROP DATABASE atomstore;
Now create database again:
mysql> CREATE DATABASE atomstore;
Exit and close the session:
mysql> quit
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- What is My root Password for MySQL Database Server?
- What is my root password for MySQL?
- Mysql user creation - setting up a MySQL new user account
- How do I access MySQL server from the shell prompt (command line)?
- Restore a backup of a MySQL Database Server
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!



March 11th, 2008 at 10:25 am
Alternative methods:
In PHPMyAdmin, you can check all tables and then choose with selected: drop.
If you are doing it with scripting, You can use SHOW TABLES to list the tables, and use this to generate a query DROP TABLE [tablename],[tablename]…
May 16th, 2008 at 8:41 pm
You can have the drop privilege, but not the create database one!!
BE CAREFUL WHEN DOING THIS! You might end up with no DB at all.
Please don’t suggest this kind of procedures without explaining the whole nine yards.
July 1st, 2008 (4 days ago) at 3:22 pm
Unfortunately this is no use if you don’t have permissions for create database (like the situation i am currently in).