How To Delete Mysql Database

How To Delete Mysql Database.You can delete a MySQL database in several ways. You can use the command line or applications like MySQL Workbench or phpMyAdmin. These are the most common methods.

Delete a MySQL database from the command line/How To Delete Mysql Database.

How To Delete Mysql Database

To delete a database we will use the mysql application . Follow these steps:

  1. Access MySQLfrom the command line as root user . Do it using this command:

mysql -u root -p

  1. When you press Enteryou will have to enter the root user password. Entering it will display the mysql prompt .
  2. Now you must use the DROPstatement to drop the database. Use the following query, replacing database with the name of the database:

DROP DATABASE base_de_datos;

NOTE : MySQL will not ask for confirmation to delete the database. Do this only if you are sure you want to delete the database.

We have already deleted the database. If you want to delete a single table from the database, you must run the following commands.

  1. Access MySQLas root user  with this command:

mysql -u root -p

  1. Now you must select the database to delete with this command, replacing databasewith the name of the database:

USE base_de_datos;

  1. Use the DROPstatement to drop the table of your choice. To do this, use the following command, replacing table_name with the name of the table you want to delete:

DROP TABLE nombre_tabla

And that’s all. Let’s see now how to do it through another application.

Delete a MySQL database with phpMyAdmin/How To Delete Mysql Database

To do this, first go to phpMyAdmin. If you use a remote server, you can access it through a URL similar to / phpmyadmin , or from localhost / phpmyadmin in your local environment:

  1. Identify yourself in phpMyAdminin by entering your access data:

check php

  1. Once you have accessed phpMyAdmin, select the database you want to delete from the menu on the left.
  2. Once selected, click on the Operations tab in the upper left menu.

delete mysql

Click Delete the database (DROP) to delete the database.

How to delete a database in MySQL with SQL

The truth is that deleting a database using SQL is very easy. You must use the DROP instruction, which allows you to delete elements from a database as well as the database itself.

The drop syntax for deleting a database is as follows:

1 DROP DATABASE <nombre_base_datos>;

All you have to do is replace <database_name> with the name of the database you want to delete.

For example: If the database you want to delete is called warehouse, the syntax of the instruction would be:

1 DROP DATABASE almacen;

After executing (if you don’t know how to execute SQL in MySQL see here ) you can check if it has been eliminated by consulting the databases available on the server with the following instruction:

1 SHOW DATABASES;

If the database is no longer listed, it has been removed.

Video with step-by-step explanation

Do you have any doubts? I have recorded the whole process step by step so that you can follow it without problems:

by Abdullah Sam
I’m a teacher, researcher and writer. I write about study subjects to improve the learning of college and university students. I write top Quality study notes Mostly, Tech, Games, Education, And Solutions/Tips and Tricks. I am a person who helps students to acquire knowledge, competence or virtue.

Leave a Comment