MySQL is a database server to manage relational databases. There are some methods to delete a database from the MySQL server.
Here we are going to learn to delete a database via MySQL command line. You can use Microsoft cmd, Linux terminal or MAC terminal which one you are using.
In this tutorial, we are going to use Microsoft cmd to delete the database from the MySQL server.
Index
We are using here windows command prompt. You can find command prompt at start menu, just search for cmd and it will come up the first.
We have to login to MySQL server via login command in order to access MySQL services on the command line. Write below command and press Enter.
mysql -u root -p
Note: If you are having an error like ‘mysql is not recognized as an internal or external command, operable program or batch file.’, this error may appear if you have not set MySQL path as the global environment. In command-line please go to MySQL root directory and change directory to the bin directory and enter the above code there.
Please enter your MySQL user password to make a connection and access MySQL services.
Now we are successfully logged in to MySQL command line.
Enter ‘SHOW DATABASES‘ command in the command line to display the list of databases.
SHOW DATABASES;
We can see the list of all databases and select which one we need to delete. Here we are going to delete test_database to demonstrate.
We can drop the selected database with the DROP DATABASE command.
DROP DATABASE DATABASE_NAME;
Note: If you are using Macintosh you need to be case sensitive for the database name.
Now the test_database should no longer be available. Check databases list via show databases command again to be sure.
Read Also: How to Sort Array in PHP [Explained With Examples]
I hope now you know how to delete any database from the command line in MySQL.
Keep Coding 🙂
There is a reason big-name companies like CNN use WordPress. WordPress is a popular content…
In this tutorial, I'm going to show you how to install MySQL on your computer.…
Download Turbo C++ for windows 10 in just 7 Mb and run your first C++…
We can redirect any webpage to any other or redirect the whole domain or website…
There are lots of methods to redirect pages, like refresh-redirect from META tag, redirect from…
Include files in PHP are used in appending various global or config files. We can…