How to Delete a MySQL Database on Linux via Command Line
MySQL is the most famous open-source social information base administration framework.
This instructional exercise depicts how to erase (or drop) a MySQL or MariaDB information base through the order line.
Before you begin
All orders are executed as a managerial client (the base advantage needed to erase an information base is DROP) or with a root account.
To get to the MySQL comfort type the accompanying order and enter your MySQL root client secret word when incited:
mysql -u root -p
On the off chance that you haven't set a secret phrase for your MySQL root client you can discard the - p switch.
In the event that you have to change your MySQL root secret phrase, at that point follow this instructional exercise on resetting a MySQL root secret phrase through the order line.
List All MySQL Databases
Prior to dropping the information base, you might need to see a rundown of the relative multitude of data sets you've made . To do as such from inside the MySQL shell execute the accompanying order:
SHOW DATABASES;
The order above will print a rundown of all information bases on the worker. The yield should be like this:
+--------------------+
| Database |
+--------------------+
| information_schema |
| database_name |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
Delete a Database in MySQL
Erasing a MySQL information base is as basic as running a solitary order. This is a non-reversible activity and should be executed with alert. Ensure that you are not eliminating an off-base information base, as once you erase the data set it can't be recuperated.
It is consistently a smart thought to make a reinforcement of the information base prior to running the drop inquiry.
To erase an information base sort the accompanying order, where database_name is the name of the data set you need to erase:
DROP DATABASE database_name;
Query OK, 1 row affected (0.00 sec)
In the event that you attempt to erase an information base that doesn't exist you will see the accompanying mistake message:
ERROR 1008 (HY000): Can't drop database 'database_name'; database doesn't exist
To try not to consider mistakes to be above, utilize the accompanying order all things being equal:
DROP DATABASE IF EXISTS database_name;
Query OK, 1 row affected, 1 warning (0.00 sec)
In the yield above, Query OK implies that the inquiry was fruitful, and 1 admonition discloses to us that the information base doesn't exists and no information base was erased.
On Linux, MySQL information base and table names are case touchy.
Delete a MySQL Database with mysqladmin
You can likewise erase a MySQL information base from the Linux terminal by utilizing the mysqladmin utility.
For instance, to erase an information base named database_name, type the accompanying order and enter your MySQL root client secret word when incited:
mysqladmin -u root -p drop database_name
Conclusion
You have figured out how to erase a MySQL information base.
Don't hesitate to leave a remark on the off chance that you have any inquiries.