How to Delete a MySQL Database

Download ArticleDownload Article

This How.com.vn teaches you how to use your computer's command line to delete a MySQL database. In order to delete a MySQL database, you must have access to an account with delete privileges, such as the "root" account.

  1. How.com.vn English: Step 1 Open the MySQL...
    Open the MySQL Command Line. In order to delete a database in MySQL, you'll need to use the MySQL command line from your computer's Command Prompt (Windows) or Terminal (Mac) program.
  2. How.com.vn English: Step 2 Enter the login command.
    Type in the following, then press Enter.
    mysql -u root -p
    • If you don't have access to the root account, enter your own username in place of "root". This must be an account that has read/write privileges.
    Advertisement
  3. How.com.vn English: Step 3 Enter your password when prompted.
    Type in the password you use to log into MySQL, then press Enter.
  4. How.com.vn English: Step 4 View a list of your databases.
    Once MySQL opens, type in the following command and press Enter to see a list of your MySQL databases:
    SHOW DATABASES;
  5. How.com.vn English: Step 5 Find the name of the database you want to delete.
    Scroll through the databases until you find the one you want to delete, making sure to note its name as it appears above the database.[1]
    • If you're using a Mac, database names are case-sensitive. This means that if the database's name has capital letters, you'll need to use the proper capitalization in the "delete" command to make sure you delete the correct database.
  6. How.com.vn English: Step 6 Delete the database.
    Type in DROP DATABASE name; where name is your database's name, then press Enter. For example, to delete a database named "Flowers", you would enter the following command:
    DROP DATABASE Flowers;
  7. How.com.vn English: Step 7 Review your updated list of databases.
    You can ensure that the database was deleted by re-entering the SHOW DATABASES; command and scrolling through your available databases. The one you deleted should not be present.
  8. Advertisement

Community Q&A

Search
Add New Question
  • Question
    What does it mean if I get "Error 1010 (HY000): Error dropping database (can't rmdir './xxxxxx', errno: 39)"?
    How.com.vn English: Community Answer
    Community Answer
    You have to stop the database, go to datadir, remove that database manually and restart the database.
  • Question
    Why does a dropped database still appear and run in Workbench in the MySQL monitor?
    How.com.vn English: Community Answer
    Community Answer
    Try "sudo service mysql restart." If your MySQL service is named something else, you may have to change the command accordingly. You can also try "sudo /etc/init.d/mysql restart."
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
      Advertisement

      Video

      Tips

      • If you aren't sure whether or not the database exists, entering DROP DATABASE IF EXISTS name; will prevent an error from displaying if the database isn't registered.
      • In the unlikely event that you're deleting a database from a server not using localhost, you'll type the login command as mysql -u root -h host -p where "host" is the IP address of your server.
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!
      Advertisement

      Warnings

      • Not all users have read/write privileges. Make sure you're using an account that allows you to delete databases (e.g., the root account).
      Advertisement

      About This Article

      How.com.vn English: Jack Lloyd
      Written by:
      How.com.vn Technology Writer
      This article was co-authored by How.com.vn staff writer, Jack Lloyd. Jack Lloyd is a Technology Writer and Editor for How.com.vn. He has over two years of experience writing and editing technology-related articles. He is technology enthusiast and an English teacher. This article has been viewed 811,833 times.
      How helpful is this?
      Co-authors: 15
      Updated: August 25, 2022
      Views: 811,833
      Categories: Software
      Article SummaryX

      1. Log into the MySQL command line using an account that can delete databases (e.g., "root").
      2. Enter SHOW DATABASES; to see a list of your databases.
      3. Find the name of the database you want to delete.
      4. Enter DROP DATABASE name; where "name" is the name of the database.

      Did this summary help you?

      Thanks to all authors for creating a page that has been read 811,833 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement