Delete Database in PHPMyAdmin

  1. Delete a MySQL Database in PHPMyAdmin From CPanel
  2. Delete a MySQL Database From PHPMyAdmin in Windows
  3. Delete a MySQL Database From a Linux Terminal

We will introduce a method to delete a database in phpMyAdmin of cPanel. The database is a MySQL database. This method requires access to web hosting.

This article also introduces a method to delete a database in phpMyadmin. The database to be deleted is a MySQL database that is created locally. This method demonstrates an example using the XAMMP in the Windows system.

We will also demonstrate a method to delete a MySQL database in a Linux system. This method uses the Linux terminal.

Delete a MySQL Database in PHPMyAdmin From CPanel

We can delete any database created in cPanel by logging in with the web host account. This method demonstrates the deletion of a database in cPanel of the Bluehost.

Firstly, log in to your Bluehost account. Then the homepage appears. Click on Advanced on the side navigation bar. The cPanel appears and then moves to the Databases section. Click on the MySQL Databases option in the Databases section. There occur various options like create, check, search, repair databases. We can explore the specific database from the search option if there are many databases in the list. If there are few databases, we can easily find them from the list. We can see the options to rename and delete the databases in the action column. Chose the database you want to delete and click the option. Then a dialog box appears to confirm the permanent deletion of the database. Click on Okay to permanently delete the database. Thus, we can delete the MySQL database from the cPanel.

Delete a MySQL Database From PHPMyAdmin in Windows

We can delete a MySQL database in Windows using the XAMMP and phpMyadmin. This demonstration is carried out on a local server. The phpMyAdmin runs on the local server, and we can access it from the browser.

Firstly, open the XAMMP application and start the MySQL and Apache module. Then the both MySQL and Apache service run. Open a web browser and access the phpMyAdmin page typing the address localhost/phpmyadmin in the address bar. We can see the databases in phpMyAdmin in the sidebar of the page. Select a database that needs to be deleted. After selecting the database, another page redirects with a navigation menu. Then click on the operation menu. Scroll down, and you will find the option Remove Database. Click on the option Drop the database and click on OK when it asks to confirm the deletion. Then the database gets deleted.

We can also delete the database in phpMyAdmin, writing the SQL query. For example, click on the SQL menu from the homepage of phpMyAdmin. Then write the query DROP DATABASE test; in the text area. The test is the database that is to be deleted. Then click on the Go button below the text area. Then the database gets deleted.

Example Code:

DROP DATABASE test;

Output:

MySQL returned an empty result set (i.e. zero rows). (Query took 0.0029 seconds.)

Delete a MySQL Database From a Linux Terminal

We can delete a MySQL database in a Linux system through the MySQL queries in the terminal. We need to start the MySQL service first, enter the MySQL command line, and write queries to delete the database.

For example, open the terminal and start the MySQL service with the command sudo service mysql start. Type your password, and the MySQL service will start. Then write the command mysql -u root -p. The command directs you to enter the username and the password for MySQL. Enter your username, and password and the MariaDB monitor open in the terminal. Then write the SQL query DROP DATABASE test; and press enter. Then write the query SHOW DATABASES;. It will show all the databases in the system, and we can see that the test database does not exist in the list.

Example Code:

DROP DATABASE test;

Output:

Query OK, 0 rows affected, 1 warning (0.095 sec)
Contribute
DelftStack is a collective effort contributed by software geeks like you. If you like the article and would like to contribute to DelftStack by writing paid articles, you can check the write for us page.

Related Article - PHP MySQL

  • Count Rows in MySQL PHP