When we have to manage a database through its interfaces, with its own processor 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 to create and maintain the definition of data and the manipulation of the same through the users and passwords that we need to identify, as well as gives us their 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 you should do it. In addition, we will introduce you to the most common errors in the databases .
Index:
Why should I remove a database 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 begin to appear in the MySQL database it means that we are performing commands in our database that the server cannot understand.
If we have this kind of errors, we will have to remove the «database» so that it does not affect the operation of the code set and route lines of the program as a whole.
Some of the most common mistakes are the examples 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 cannot be created, or a file, when it is difficult to read the record in the table that contains the system, when a file cannot be locked or we cannot open it to it and when it cannot be written because the key is duplicated in some table.
Steps to remove an easy and fast MySQL database
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 program development code structure that may affect other databases or software in general.
The steps we need to perform in order to easily and safely remove a database in MySQL are the following:
- In MySQL we open the command line, either “Terminal” for the MacOS operating system or “Command Prompt” for Windows which can be accessed through a combination of «Win + X» or also through accouncmdpointed.
- 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 about it, we will have to replace “root” with our username. If the server does not use localhost we will have to type the “mysql -u root -h host -p” command, where host is the IP address.
- We type the password and select «Accept» .
- We will now describe the «show database;» command to see the list of existing databases.
- We look for the “database” that we want to delete.
- Once we have found the database, we will write “drop database name the database to be deleted;” .
By confirming that the database has been successfully deleted, we can verify if it appears in the list using the «show database;» command.
Keep in mind that, if we use a Mac computer, the names that appear in the databases are in upper and lower case letters, so we have to take into account when deleting.
When we are not sure if the “database” exists we can use the command “drop database IF EXISTS name of the database we want to control;” to verify no that database is registered.