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

  1. Log in to your cPanel account.
  2. 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:

  1. Check the box next to the table(s) you want to empty.
  2. From the "With selected:" dropdown at the bottom, select Empty.
  3. Confirm the action when prompted. This executes a TRUNCATE or DELETE FROM command, removing all data but keeping the table intact.

Step 4: Empty All Tables in a Database

To clear the entire database:

  1. Check Select All (the checkbox at the top of the table list).
  2. From the "With selected:" dropdown, choose Empty.
  3. 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:

  1. Select all tables as above.
  2. Choose Drop from the dropdown.
  3. 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. Drop permanently 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 with SET 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.
Was this answer helpful? 0 Users Found This Useful (0 Votes)