How to Delete a Database in MySQL/MariaDB

Posted on by J. Mays | Updated:
Reading Time: 2 minutes

Getting Started

These instructions intend to show how to delete a database in MySQL. We will be working from a Liquid Web Core Managed Linux server with CentOS 7.

How to Delete A Database In MySQL/MariaDB

Video by Andrew Casares

First, we'll log in to the MySQL server from the command line as root with the following command.

mysql -u root -p

In this case, I've specified the user root with the -u flag and then used the -p flag, so MySQL prompts for a password. Enter your current password to complete the login. If you need to change your root (or any other) password in the database, follow this tutorial to change a password for MySQL via the command line.

You should now be at a MySQL prompt that looks very similar to this.


Follow this tutorial if you have not yet created a database or you want a list of databases.

Delete a Database in MySQL

It only takes a straightforward command to delete a database in MySQL, but BEWARE; when you remove a MySQL database, you can not undo it! 

The following is the command to delete your database in MySQL. If the database tutorial_database exists, the command will altogether remove it.

DROP DATABASE tutorial_database;

If a database with the name tutorial_database does not exist, then you'll receive this error.

ERROR 1008 (HY000): Can't drop database 'tutorial_database'; database doesn't exist

To avoid seeing this error use the following command instead.

DROP DATABASE IF EXISTS tutorial_database;

The above command will only drop the database tutorial_database if a database of that name exists.

Get 75% off a VPS!

View All MySQL Databases

To view a list of databases, simply issue the following command.


Your result should be similar to this.

 | Database           |
 | information_schema |
 | mysql              |
 | test               |
 4 rows in set (0.00 sec)


In this tutorial, we covered how to delete a MySQL database from the command line in Linux. We also showed how to view your databases as well. If you prefer a visual tutorial, we included a handy video that presents a visual representation of removing your MySQL database.

Liquid Web customers also receive 24/7/365 support from our team of knowledgeable Linux administrators. If you need a new server from a trusted managed hosting provider, chat with our sales team to find the right fit for your needs.

Series Navigation
<< Previous ArticleNext Article >>
Avatar for J. Mays

About the Author: J. Mays

As a previous contributor, JMays shares his insight with our Knowledge Base center. In our Knowledge Base, you'll be able to find how-to articles on Ubuntu, CentOS, Fedora and much more!

Latest Articles

What is Bare Metal Programming?

Read Article

Useful Features in cPanel for Your Sites

Read Article

How to Clone a Drupal Site to Another Domain

Read Article

Accessing Man Pages on Ubuntu 16.04 LTS

Read Article

What is VMware Fusion?

Read Article