Site icon Sudhanshu's Blog

Magento 2: How to delete all customers data?

Please take backup of the database.

Following MySql queries truncate all the customer related data. Tested on Magento 2.4 Open Source.

SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `amazon_customer`;
TRUNCATE TABLE `customer_address_entity`;
TRUNCATE TABLE `customer_address_entity_datetime`;
TRUNCATE TABLE `customer_address_entity_decimal`;
TRUNCATE TABLE `customer_address_entity_int`;
TRUNCATE TABLE `customer_address_entity_text`;
TRUNCATE TABLE `customer_address_entity_varchar`;
TRUNCATE TABLE `customer_entity`;
TRUNCATE TABLE `customer_entity_datetime`;
TRUNCATE TABLE `customer_entity_decimal`;
TRUNCATE TABLE `customer_entity_int`;
TRUNCATE TABLE `customer_entity_text`;
TRUNCATE TABLE `customer_entity_varchar`;
TRUNCATE TABLE `customer_grid_flat`;
TRUNCATE TABLE `customer_log`;
TRUNCATE TABLE `customer_visitor`;
TRUNCATE TABLE `persistent_session`;
TRUNCATE TABLE `login_as_customer`;
TRUNCATE TABLE `magento_login_as_customer_log`;
TRUNCATE TABLE `wishlist`;
TRUNCATE TABLE `wishlist_item`;
TRUNCATE TABLE `wishlist_item_option`;
TRUNCATE TABLE `salesrule_customer`;
SET FOREIGN_KEY_CHECKS = 1;

Happy Coding šŸ™‚

Exit mobile version