Remove all product attributes in WooCommerce programmatically with SQL

Looking to programmatically remove all product attributes in WooCommerce through phpMyAdmin and SQL? Here’s how you can do this.

Delete all WooCommerce product attributes with SQL

In order to remove all product attributes using SQL, you’ll need to login to your phpMyAdmin database and click SQL. If you don’t have access to phpMyAdmin (i.e. you’re running your website through a VPS), you could try to access MySQL directly via the command line.

Once you’re able to write your SQL code, enter the code below.

DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%');
DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%';
DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy);

Note, before you do this, it’s always good practice to backup your database beforehand by exporting it, in case of any mistakes.