The command DROP DATABASE per­ma­nent­ly deletes entire databases in MariaDB. Therefore, the command can only be executed with root or admin priv­i­leges and should be used with great caution.

DROP DATABASE in MariaDB

DROP DATABASE is a very effective statement for MariaDB, which should only be used extremely carefully. It is used to delete a database from a server structure. Once the command has been executed, the entire database including all tables and data is ir­re­triev­ably lost and can no longer be accessed. Only user rights that were es­tab­lished when using MariaDB CREATE USER are not au­to­mat­i­cal­ly revoked. DROP DATABASE can only be executed in MariaDB with admin or root priv­i­leges. Other commands such as DELETE DATABASE for MariaDB or REMOVE DATABASE for MariaDB do not exist.

Managed Database Services
Time-saving database services
  • En­ter­prise-grade ar­chi­tec­ture managed by experts
  • Flexible solutions tailored to your re­quire­ments
  • Leading security in ISO-certified data centers

Syntax with and without IF EXISTS

The syntax of DROP DATABASE in MariaDB is as follows:

DROP DATABASE Name_of_database;
sql

Replace the place­hold­er “Name_of_database” with the name of the specific database you want to delete.

You can op­tion­al­ly include IF EXISTS to avoid receiving an error message if the database is not found on your server.

DROP DATABASE IF EXISTS Name_of_database;
sql

How does DROP DATABASE in MariaDB work?

To il­lus­trate how DROP DATABASE works in MariaDB, we will use a simple example. Let’s imagine that a database called “Tasks_2023” is no longer needed. Therefore, we use SHOW DATABASES to check if the database is still on the server and then remove it. This is the code:

mysql> SHOW DATABASES;
mysql> DROP DATABASE Tasks_2023;
sql
Tip

In our Digital Guide we also reveal how to create a new database with MariaDB CREATE DATABASE and how to call up a database with MariaDB SELECT DATABASE. You will also find a MariaDB and MySQL com­par­i­son and learn every­thing you need to know about in­stalling MariaDB.

Go to Main Menu