Deleting a MySQL database via the command

Blue databaseThere are two ways to interact with your MySQL/MariaDB database. The first is via a graphical user interface (GUI) such as phpMyAdmin which works with both MySQL and MariaDB. The second way to interact with the database is via the command line.

We are going to show you how to delete a database from the command line. You can execute these commands from either a SSH terminal session or from within phpMyAdmin via the SQL tab. The SQL tab lets you run the MySQL queries from within phpMyAdmin.

There are two simple commands to delete a database. Both are really similar and the only difference is one will show error messages if the database you want to delete doesn’t exist and the other command will only delete a database if it exists.

The following MySQL command will only delete a database that is named mydatabase if it exists. If that database doesn’t exist it won’t delete anything or show any error messages.

DROP DATABASE IF EXISTS mydatabase;

This command will delete the database, mydatabase and it will show an error message if no such database exists.

DROP DATABASE mydatabase;

20% Off WP Engine
About VNKB | Advertising | Disclosures | Terms of Use | Privacy Policy | DMCA | Contact VNKB
VNKB is a trademark of VNKB.com
Copyright Ā© 2007-2016 VNKB.com All Rights Reserved.