How to empty a MySQL database

There are two ways to empty a MySQL database: via phpMyAdmin and SSH.

NOTE 1: By default, SSH access is disabled on all our shared servers. If you need SSH to be enabled, contact our Hosting support via Live Chat or submit a ticket to the Hosting department.

NOTE 2: We recommend making a backup of your database before proceeding with any changes.

Using phpMyAdmin

To empty a database follow these steps:

1. Go to cPanel >> Databases section >> phpMyAdmin menu.

You can quickly access phpMyAdmin using cPanel Shortcuts in the Namecheap account.

2. Select the database you wish to empty. A list with all the database tables will appear on the left (you may have just one database if only one website is hosted):

3. Tick Check All to select all tables and choose the Drop option from the With selected drop-down list:

4. This will execute the DROP TABLE SQL query to empty all the tables at once. On the next step, confirm you wish to proceed by clicking the Yes button:

Using SSH

When you have a large database, it can be quicker to drop the database via SSH:

1. First, check if the database user has the privileges to Drop and Create. Go to cPanel > Databases section > MySQL Databases menu:

2. Find the database you wish to drop and click the assigned username:

3. You will see what privileges this user has. Make sure Drop and Create options are selected. If these options are not ticked, select them and click Make Changes:

3. Connect to the hosting account via SSH. You can find the detailed instructions here.

4. Once connected, run the following command:
mysql -uUsername -pPassword

Username - the MySQL user assigned to the database you are working with.
Password - password for the MySQL user.

5. You should receive the following output:

6. To drop the database run this command:
 drop database database_name 
where database_name is the name of your database:

That's it!

Need any help? Contact our HelpDesk

34254 times

Need help? We're always here for you.