How To Drop a Database on MySQL

MySQL is a Relational Database Management System that is known for being very easy to use, nice interface, and also fast. In this article, we will take a look at such database management techniques as deleting a database in MySQL. To get started with MySQL, open a terminal. First, check your MySQL version with the following command:

mysql - V

Check for the latest up-to-date database version. If it is, then proceed to the step of checking the status of the system mysql.service. To do this, run the following command:

sudo systemctl status mysql

If the service is not active, start the service

sudo systemctl start mysql

After starting the service, connect to the MySQL client or log into the MySQL shell as the root user. If you do not have access to the root user account, replace β€œroot” with your username

sudo mysql -u root -p

After logging into MySQL, list the databases with SHOW DATABASES command:

SHOWDATABASES;

After you have a list of databases, then you need to select the database in which you want to delete. If you want to drop an existing database, you can run a simple DROP DATABASE command along with the database name like this:

DROPDATABASE your_database_name;

After deleting the database, you need to list the databases again, for this use the SHOW DATABASES command

SHOWDATABASES;

Now it is possible to notice that the remote database no longer exists in MySQL.

Was this article helpful?

Related Articles

Leave A Comment?