Skip to content
Step by Step Internet 馃寪 Guides for learning to surf the Net

How to delete a database in MySQL easy and fast? step by step guide

UPDATED ✅ Need to remove a buggy MySQL database safely? ⭐ ENTER HERE ⭐ and discover how to do it ✅ EASY and FAST ✅

When we have to manage a database through its interfaces, with a processor’s own language, as well as we need to dedicate ourselves to the storage mechanism with a search and transaction engine, MySQL is the ideal manager to control, design and protect databases.

MySQL helps us create and maintain the definition of data and the manipulation of the same through users and passwords that we need to identify, as well as giving us its support in the generation of applications so that we can manage and develop them.

In this post we will talk about why you should delete a database with errors and we will show you how to do it. In addition, we will present the most common errors that exist in the databases.

Why should I delete a DB with errors in MySQL?

MySQL is a tool used to enter, modify and extract data from a “database”. Thanks to this program you can also control user access and data protection.

When error messages start to appear in the MySQL database it means that we are performing commands on our database that the server cannot understand.

If we have this kind of errors, we will have to delete the “database” so that it does not affect the operation of the set of codes and line paths of the program as a whole.

Some of the most common errors are the examples that we present below:

  • Error: 1008 SQLSTATE: HY000 (ER_DB_DROP_EXISTS)
  • Error: 1010 SQLSTATE: HY000 (ER_DB_DROP_RMDIR)
  • Error: 1015 SQLSTATE: HY000 (ER_CANT_LOCK)
  • Error: 1019 SQLSTATE: HY000 (ER_CANT_SET_WD)
  • Error: 1021 SQLSTATE: HY000 (ER_DISK_FULL)

With these errors we can discover when a table or a file cannot be created, when it is difficult to read the record in the table that contains the system, when a file cannot be locked or we also cannot open it at the same time and when it cannot be written because the key is duplicated in some table.

Steps to delete a MySQL database easily and quickly and without risks

Steps to delete a MySQL database easily and quickly and without risks

If we have detected that our database is not well designed, we will have to eliminate it, but at the same time we have to be careful not to touch the structure of the program’s development codes that may affect other databases or software in general.

The steps we need to take to be able to easily and safely delete a database in MySQL are as follows:

  • In MySQL we open the command line, either “Terminal” for the MacOS operating system or “Command Prompt” for Windows which we can access through a combination of “Win + X” or also through “cmd”.
  • To start the session we will write “mysql -u root -p”. It should be noted that, if we have access as a user to be able to read and also write to it, we will have to replace root by our username. If the server does not use localhost we will have to write the command “mysql -u root -h host -p”where host is the IP address.
  • We write the password and select “To accept”.
  • We will now describe the command “showdatabase;” to see the list of databases that exist.
  • We look for the “database” that we want to delete.
  • Once we have found the DB, we will write “drop database name the DB to delete;”.

By verifying that the DB has been correctly deleted, we can verify if it appears in the list using the command “showdatabase;”.

Keep in mind that, if we use a Mac computer, the names that appear in the databases are in uppercase and lowercase letters, so we have to take this into account when deleting.

When we are not sure if there is “data base” we can use the command ” drop database IF EXISTS name of the database we want to control;” to verify that DB is not registered.

Computing