 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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".
Advertisements
 