How to Drop a MySQL Database on Linux via Command line

banner dedicated


We will show you how to drop a database in command line on a linux server with MySQL or MariaDB installed.


First you need to log your MySQL/MariaDB

mysql -u root -p


List all the databases

MariaDB> show databases;         
+--------------------+
| Database           |
+--------------------+
| information_schema |
| example            |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)


Drop the database

In this example, we will erase the database “example”

MariaDB> DROP DATABASE example;


Check if the database is erased

MariaDB> show databases;         
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)


banner dedicated


Colo-Serv Communications has written 32 articles

Premium Dedicated Hosting Services