How to permanently delete a database using DROP DATABASE in MariaDB
The command DROP DATABASE
permanently deletes entire databases in MariaDB. Therefore, the command can only be executed with root or admin privileges 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 irretrievably lost and can no longer be accessed. Only user rights that were established when using MariaDB CREATE USER are not automatically revoked. DROP DATABASE
can only be executed in MariaDB with admin or root privileges. Other commands such as DELETE DATABASE
for MariaDB or REMOVE DATABASE
for MariaDB do not exist.
- Enterprise-grade architecture managed by experts
- Flexible solutions tailored to your requirements
- Hosted in the UK under strict data protection legislation
Syntax with and without IF EXISTS
The syntax of DROP DATABASE
in MariaDB is as follows:
DROP DATABASE Name_of_database;
sqlReplace the placeholder ‘Name_of_database’ with the name of the specific database you want to delete.
You can optionally 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;
sqlHow does DROP DATABASE in MariaDB work?
To illustrate 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;
sqlIn 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 comparison and learn everything you need to know about installing MariaDB.