How can I empty a MySQL database?

You can empty the content of a MySQL database via phpMyAdmin or SSH. We would highly recommend you to create a backup of your database (phpMyAdmin or SSH) prior making any changes to your databases.

  • Using phpMyAdmin

This is by far the easiest way to empty a MySQL database.

Once in phpMyAdmin, select the database you wish to empty.

A list with all the database's tables will appear. Click Check All to select all tables.

Click the box With selected: and choose Drop. This will execute the DROP TABLE SQL query on all tables and once you confirm that you wish to proceed the database will be emptied.

  • Using SSH

Dropping the content of a database via SSH is very useful when you are dealing with large databases. In order to use the steps below you must have the drop and create database privilege (otherwise you will drop database but not able to create it again).

SiteGround customers can check this tutorial on how to connect to SSH to their hosting accounts.

Access MySQL with your database MySQL user by running the following command over SSH:

mysql -uUSERNAME -p

Make sure that you will replace USERNAME with your MySQL user and place it's password when prompted.

After that execute the following DROP and CREATE commands:

mysql> DROP database DATABASE_NAME;

mysql> CREATE database DATABASE_NAME;

Where DATABASE_NAME is the name of your database.

cPanel is easy to work with when you have the right host to support you. If you need a reliable partner to help you manage your website with cPanel, check out our cPanel hosting services!