If you need to clear all data from a MySQL database — for example, before restoring a backup or reinstalling an application — you can do so through phpMyAdmin in your cPanel. This guide covers how to empty individual tables and how to empty (truncate) an entire database.
Step 1: Open phpMyAdmin
- Log in to your cPanel account.
- Under the Databases section, click phpMyAdmin.
Step 2: Select Your Database
Click the database name in the left sidebar. All tables in the database will be listed.
Step 3: Empty Individual Tables
To remove all rows from a specific table without dropping its structure:
- Check the box next to the table(s) you want to empty.
- From the "With selected:" dropdown at the bottom, select Empty.
- Confirm the action when prompted. This executes a
TRUNCATEorDELETE FROMcommand, removing all data but keeping the table intact.
Step 4: Empty All Tables in a Database
To clear the entire database:
- Check Select All (the checkbox at the top of the table list).
- From the "With selected:" dropdown, choose Empty.
- Confirm the action. This will truncate all tables in the database, removing all data while preserving the table structures.
Alternative — Drop and Recreate: If you want to remove both the data and the table structures entirely:
- Select all tables as above.
- Choose Drop from the dropdown.
- Confirm the action. This permanently deletes all tables and their data. You will need to re-import your database structure afterwards.
Step 5: Verify
After emptying or dropping tables, click any table on the left to confirm it contains zero rows. For a freshly dropped database, you will need to re-import a SQL file or let your application recreate the tables.
Important Notes
- Always back up your database first. In phpMyAdmin, click Export to download a full SQL backup before making any destructive changes.
Empty(TRUNCATE) removes all rows but keeps the table structure.Droppermanently deletes the table and its structure.- Some web applications (e.g., WordPress, WooCommerce) store configuration data in the database tables. Emptying tables will remove settings, posts, users, and all other application data.
- If you are preparing a database for a fresh import, using Drop followed by re-importing your SQL backup file is often the cleanest approach.
- Foreign key constraints may prevent truncating certain tables. In that case, drop and re-import is the recommended method.
Troubleshooting
- "Cannot truncate" due to foreign key constraints: Disable foreign key checks temporarily by running:
SET FOREIGN_KEY_CHECKS=0;then truncate your tables, then re-enable withSET FOREIGN_KEY_CHECKS=1;. You can run these via the SQL tab in phpMyAdmin. - No tables listed: Ensure you have selected the correct database from the left sidebar. If the database appears empty, the tables may have already been dropped.
- Import errors after dropping tables: Make sure your SQL backup file is complete and uncorrupted. Upload it via Import in phpMyAdmin or restore it from your cPanel backups.
- Permission denied: Your cPanel database user may not have sufficient privileges. Contact your hosting provider if you encounter access errors.