Atlantic.Net Blog

How to Delete or Remove Databases in MySQL

Hitesh Jethva
by Atlantic.Net (395 posts) under Dedicated Server Hosting, Tutorials
0 Comments

If you are a database or Linux system administrator, then you may often need to delete unwanted databases from your system. There are several ways to delete a MySQL database in Linux. You can either use the MySQL command-line or phpMyAdmin to delete a MySQL database. You must have a MySQL user account with delete privileges to delete a MySQL database from your system.

In this tutorial, we will show you how to delete (or drop) a MySQL or MariaDB database in Linux.

Prerequisites

  • A server running Linux on the Atlantic.Net Cloud Platform
  • A root password configured on your server

Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing any Linux operating system with at least 1GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Delete MySQL Database with mysqladmin

mysqladmin is a MySQL built-in command-line utility that allows you to create and delete MySQL databases, check MySQL processes, and set a MySQL root password via a command-line interface.

First, use the following command to list all available databases in your system:

mysqlshow -u root -p

You will get a list of all databases in the following output:

+--------------------+
|     Databases      |
+--------------------+
| drupaldb           |
| information_schema |
| magentodb          |
| mysql              |
| performance_schema |
| sys                |
| wpdb               |
+--------------------+

Now, pick the drupaldb database from the above list and delete it by running the following command:

mysqladmin -u root -p drop drupaldb

You should see the following output:

Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.

Do you really want to drop the 'drupaldb' database [y/N] y
Database "drupaldb" dropped

Delete MySQL Database within MySQL Console

MySQL databases can also be deleted after logging into the MySQL shell. To do so, log into the MySQL console with the root user using the following command:

mysql -u root -p

Once you are logged in, you should see the following output:

Next, list all available databases with the following command:

mysql> show databases;

You should see all databases in the following output:

+--------------------+
| Database           |
+--------------------+
| drupaldb           |
| information_schema |
| magentodb          |
| mysql              |
| performance_schema |
| sys                |
| wpdb               |
+--------------------+

Next, delete the MySQL database named magentodb from the above list with the following command:

mysql> drop database magentodb;

Next, exit from the MySQL console with the following command:

mysql> exit;

You can also delete the MySQL database named wpdb without logging into the MySQL console as shown below:

mysql -u root -p -e "drop database wpdb";

Delete MySQL Database with PhpMyAdmin

Before starting, make sure phpMyAdmin is installed on your server.
Next, open your web browser and access the PhpMyAdmin web UI using the URL http://your-server-ip/phpmyadmin. You should see the following page:
phpMyAdmin login page
Provide your MySQL root username and password and click on the Go button. You will be redirected to the PhpMyAdmin dashboard on the following page:
phpMyAdmin dashboard page
Now, click on Databases. You should see all the databases on the following page:
phpMyAdmin drop database page
Now, select the database you want to delete and click on the Drop button to delete the selected database.

Conclusion

In the above post, we explained how to delete a MySQL database via command-line and PhpMyAdmin. Try it on dedicated hosting from Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

How to Install Apache Solr on Oracle Linux 8
How to Install Apache Cassandra on Oracle Linux 8
How to Install Yarn NPM Package Manager on Oracle Linux 8
How to Install Apache Spark on Oracle Linux 8
How to Install Docker and Docker Compose on Oracle Linux 8

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2008 Lookout Dr,

Dallas, Texas 75044

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources