About Linux FAQ

Browse More FAQs:

MySQL empty database / delete all tables

Posted by Vivek Gite [Last updated: May 1, 2007]

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:

Discussion on This FAQ

  1. Jon Says:

    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]…

  2. romina Says:

    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.

  3. Colin Says:

    Unfortunately this is no use if you don’t have permissions for create database (like the situation i am currently in).

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!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.