If you Delete all WooCommerce products from the database If you want to do something specific—for example, before a large CSV import, a shop reset, or a data migration—using the WordPress admin interface is too slow for more than 200 products and often leads to timeouts. The direct SQL approach is significantly faster, but it has its drawbacks: orphaned post metas, hanging term relationships, images in the upload folder, and, last but not least, the caching problem. We'll show you the complete process.
Before deleting: Mandatory backups
- Full database backup (e.g., via mysqldump or your hosting backup).
- Full backup of
wp-content/uploads/if you also delete product images. - Note the current number of products:
SELECT COUNT(*) FROM wp_posts WHERE post_type='product'.
Method: Direct SQL command in phpMyAdmin (original)
Deleting all WooCommerce products directly from the database should be approached with caution, as it can cause irreversible data loss. It's always good practice to create a full backup of your website before making such changes.
Here's how to delete all WooCommerce products using SQL commands in phpMyAdmin. These instructions apply to a standard WooCommerce installation. If you have custom tables or configurations, you'll need to adjust them accordingly.
- Create a backupMake sure you have a full backup of your database before making any changes.
- Open phpMyAdminLog in to your web hosting control panel, find the database management area and open phpMyAdmin.
- Select database: On the left side, select the database that contains your WordPress website data.
- Execute SQL commandGo to the "SQL" or "Execute SQL" tab in phpMyAdmin, where you can execute SQL commands directly. Here is the basic SQL command you would use to delete all products:
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE taxes.taxonomy='product_type';
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';
Please note that table prefixes can vary; by default it is wp_, but it might be different in your installation, and you will need to adjust the SQL code accordingly.
- clean up databaseAfter deleting the products, there may still be orphaned metadata that should be cleaned up. Check for other possible orphaned entries in the database that could be related to the deleted products.
- Check websiteAfter the commands have been executed, check your website to ensure that everything is working as expected.
Again, this method can permanently delete all product information, so use it with caution and make sure you have a backup to fall back on. If you are unsure about this process, consider consulting a professional.
Alternative 1: WP-CLI (clean method)
Those with SSH access should use WP-CLI — it respects hooks and cache:
# Alle Produkt-IDs holen
wp post list --post_type=product --format=ids > product_ids.txt
# Bei wenigen Produkten direkt löschen
wp post delete $(wp post list --post_type=product --format=ids) --force
# Bei vielen Produkten in Batches
xargs -a product_ids.txt -n 100 wp post delete --force
Alternative 2: Plugin (for smaller shops)
Plugins like WP Bulk Delete or WP-Reset They offer a GUI version. Advantage: all WordPress hooks (e.g., WooCommerce inventory update hooks) are executed correctly. Disadvantage: slower than SQL, often timeout problems with very large catalogs.
What is often forgotten after deletion
- Orphaned postmeta:
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts p ON pm.post_id = p.ID WHERE p.ID IS NULL; - Update term counts: in WP-Admin → Products → Categories the counters are otherwise incorrect.
wp term recount product_cat product_tag - Clear the cache: Explicitly flush WooCommerce transients and object cache (Redis/Memcached).
- Check index tables:
wp_wc_product_meta_lookupand similar WC lookup tables, they should be empty. - Regenerate sitemap — the old product URLs must be removed from the sitemap, otherwise GSC will report a 404 error for deleted products.
Frequently Asked Questions about Bulk Delete
Will orders also be deleted?
No — only posts of that type productOrders are shop_order and remain unchanged. However, existing orders lose access to deleted product details, which can be problematic in the case of complaints.
What happens to the product images?
The attachment-Entries remain in wp_posts and the files in the upload folder. If you also want to remove the images: wp media regenerate with prior orphan cleanup via Media Cleaner Pro or a similar plugin.
Can I still recover data after an accidental mass delete?
Only via database backup — the trash folder is bypassed during SQL DELETE. Therefore, a backup before the command is absolutely essential.
Do you also offer this as a service?
Yes — we reset WooCommerce shops to production and perform data migrations with a complete SEO redirect map. Inquiries via WooCommerce agency Hamburg.
Secure shop setup from the start
If you're resetting your shop anyway, it's often a good time to completely rethink your setup—from performance and SEO to security hardening. Learn more at Have a shop created.








Be the first to leave a comment!