How can I empty a MySQL database?
To empty the content of a MySQL database use phpMyAdmin or SSH. It is highly recommended to create a backup of your database (phpMyAdmin or SSH) prior to 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. To use the steps below you 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 its 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.