
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How do I remove a MySQL database?
To remove any database, we need to use DROP command in MySQL. Here is the syntax.
DROP DATABASE yourDatabaseName;
First, let us check how many databases are present in MySQL. Here is the query for the same.
mysql> SHOW DATABASES;
The following is the output.
+--------------------+ | Database | +--------------------+ | business | | database1 | | databasesample | | education | | hello | | information_schema | | javadatabase | | javadatabase2 | | javasampledatabase | | mybusiness | | mydatabase | | mysql | | performance_schema | | sample | | sampledatabase | | schemasample | | sys | | test | | test3 | | universitydatabase | +--------------------+ 20 rows in set (0.00 sec)
As displayed above, we have total 20 databases in MySQL. Here, let us try to remove database ‘javadatabase’.
The following is the query to remove database.
mysql> DROP DATABASE javadatabase; Query OK, 0 rows affected (0.19 sec)
We have successfully removed the “javadatabase”. To verify, let us check with the help of SHOW command.
mysql> show databases;
The following is the output.
+--------------------+ | Database | +--------------------+ | business | | database1 | | databasesample | | education | | hello | | information_schema | | javadatabase2 | | javasampledatabase | | mybusiness | | mydatabase | | mysql | | performance_schema | | sample | | sampledatabase | | schemasample | | sys | | test | | test3 | | universitydatabase | +--------------------+ 19 rows in set (0.00 sec)
The above output displays 10 databases now i.e. we have successfully removed the “javadatabase”. Now, you can’t find any database with the name “javadatabase”.
- Related Articles
- How do I remove a uniqueness constraint from a MySQL table?
- How do I show the schema of a table in a MySQL database?
- How do I see what character set a MySQL database / table / column is?
- How do I select four random tables from a MySQL database having thousands of tables?
- How do I get the id after INSERT into MySQL database in Python?
- How to remove special characters from a database field in MySQL?
- How do I remove ON UPDATE CURRENT_TIMESTAMP from an existing column in MySQL?
- How do I remove a property from a JavaScript object?
- How do I drop a MongoDB database from the command line?
- How do I access SQLite database instance on iPhone
- How can I get enum possible values in a MySQL database?
- How do I create a view in MySQL?
- How do I insert a record from one Mongo database into another?
- How do we insert/store a file into MySQL database using JDBC?
- How do I remove multiple elements from a list in Java?

Advertisements