In this tutorial you are going to learn how to delete a MySQL database via command line on Linux server. Also, you'll learn basic MySQL database operations through below steps.
Let's get straight to the point.
How to access MySQL command line or shell?
If MySQL server already installed on your server, then you can access it through shell or command line.
First, login to the server as a root and then enter below command to access MySQL shell interface.
You can use any of the below commands to access MySQL command line.
mysql
mysql -u root -p
In the above command u flag indicates root user, and -p flag for password authentication.
You have to enter password to access MySQL.
mysql>
Now, you are ready to delete a database!
How to Delete or Drop MySQL Database?
You can delete/drop a database with simple command. Keep in mind that you can't undo delete once executed. You'll lose all data in database.
DROP DATABASE sampledb;
The above command will drop or delete the database named "sampledb". You may receive error if database doesn't exist.