If you want to delete all WooCommerce products from the database — for example before a large CSV import, a shop reset or a data migration — the WordPress admin is too slow once you have more than 200 products and often runs into timeouts. The direct SQL approach is much faster, but it has its pitfalls: orphaned postmeta, leftover term relationships, images in the uploads folder and, not least, the cache problem. We walk you through the complete process.
Before deleting: required backups
- Full database backup (e.g. via mysqldump or your hosting backup).
- Full backup of
wp-content/uploads/if you are also deleting 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 in the database should be handled with care, as it can cause irreversible data loss. It is always good practice to create a full backup of your website before making changes like these.
Here is how to delete all WooCommerce products using SQL commands in phpMyAdmin. These instructions apply to a standard WooCommerce installation. If you use custom tables or configurations, you will need to adjust them accordingly.
- Create a backup: Make sure you have a full backup of your database before making any changes.
- Open phpMyAdmin: Log in to your web hosting control panel, find the database management section and open phpMyAdmin.
- Select the database: On the left, select the database that contains your WordPress site data.
- Run the SQL command: Go to the “SQL” or “Run SQL” tab in phpMyAdmin, where you can run 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';
Note that table prefixes can vary; the default is wp_, but it may be different in your installation, in which case you need to adjust the SQL code accordingly.
- Clean up the database: After deleting the products, there may still be orphaned metadata that should be cleaned up. Check for any other orphaned entries in the database that may be related to the deleted products.
- Check your website: Once the commands have run, check your website to make sure everything works as expected.
Again, this method can permanently delete all product information, so use it with care 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 (the clean method)
If you have SSH access, use WP-CLI — it respects hooks and the 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 such as WP Bulk Delete or WP Reset offer a GUI option. Advantage: all WP hooks (e.g., WooCommerce stock update hooks) run correctly. Disadvantage: slower than SQL, with frequent timeout issues on very large catalogs.
What is often forgotten after deleting
- 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: otherwise the counts under WP Admin → Products → Categories will be wrong.
wp term recount product_cat product_tag - Clear the cache: explicitly flush WooCommerce transients and the object cache (Redis/Memcached).
- Check index tables:
wp_wc_product_meta_lookupand similar WC lookup tables should be empty. - Regenerate the sitemap — the old product URLs have to be removed from the sitemap, otherwise GSC will report 404s for deleted products.
Who wrote this article
Storetown Media is a WooCommerce agency based in the Pinneberg district near Hamburg. Working directly in the database is part of our daily routine — with the advice no tutorial should leave out: back up first, verify afterward, and never do it while the shop is live and selling.
Bulk delete FAQ
Are orders deleted as well?
No — only posts of type product. Orders are shop_order and remain unchanged. However, existing orders lose access to the details of deleted products, which can cause problems when handling complaints.
What happens to the product images?
The attachment entries remain in wp_posts and the files stay in the uploads folder. If you want to remove the images as well: run wp media regenerate after an orphan cleanup with Media Cleaner Pro or a similar plugin.
Can I recover after an accidental mass delete?
Only from the database backup — an SQL DELETE bypasses the trash. That is why a backup before running the command is absolutely mandatory.
Do you offer this as a service?
Yes — we reset live WooCommerce shops and carry out data migrations with a complete SEO redirect map. Get in touch via WooCommerce agency Hamburg.
A secure shop setup from the start
If you are resetting the shop anyway, it is often a good time to rethink the entire setup — from performance and SEO to security hardening. Learn more on Have your shop built.






















{% endif %}
{% if title and title != "" %}
{{ title }}
{% endif %}
{% if excerpt and excerpt != "" %}