Delete a MySQL Database on Linux via Command Line

MYSQL Articles, Errors and Fixes
MYSQL Articles, Errors and Fixes

Delete a mysql database on linux:

Pre-Flight Check

These directions are supposed for deleting a MySQL information on LINUX via the program line.

I’ll be engaging from a Liquid internet Core Managed CentOS seven server, and I’ll be logged in as root.

First we’ll login to the MySQL server from the program line with the subsequent command:

mysql -u root -p

In this case, I’ve nominal the user root with the -u flag, so used the -p flag so MySQL prompts for a parole. Enter your current parole to finish the login.

If you wish to alter your root (or any other) parole within the info, then follow this tutorial on ever-changing a parole for MySQL via the statement.

You should currently be at a MySQL prompt that appears terribly kind of like this:


Delete a Database in MySQL

It only takes one simple command to delete a database in MySQL, but BEWARE; dropping a database can not be undone! The command is as follows:

DROP DATABASE tutorial_database;

If a database of 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.

View All MySQL Databases

To view a list of databases simply issue the following command:


Your result should be similar to this:

MySQL database


READ  How Hackers Use SQL Injections to Get Access of Websites

About the author

Venkatesan Prabu

Venkatesan Prabu

Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I'm a frequent speaker at tech conferences and events.

Add Comment

Click here to post a comment