Jigar KarangiyaJigar Karangiya

How to Remove Sample Data from Magento 2

JK
Jigar Karangiya
· 2 min read
How to Remove Sample Data from Magento 2

In this blog post, we will learn how to remove sample data from Magento 2. Sample data is useful for development and testing, but it’s not needed in a production environment. Let’s see how we can remove it.

Prerequisites

Before we start, ensure that you have:

  • Installed Magento 2
  • Access to the command line interface (CLI) of the server where Magento 2 is installed

Steps to Remove Sample Data

Step 1: Access the Server

First, you need to access the server where Magento 2 is installed. This can be done through SSH or any other method you prefer.

Run
ssh user@yourserver

Step 2: Navigate to the Magento 2 Directory

Once you’re in, navigate to the directory where Magento 2 is installed.

Run
cd /path/to/your/magento2

Step 3: Remove Sample Data

Magento 2 provides a command-line tool that we can use to remove sample data. Run the following command:

Run
php bin/magento sampledata:remove

Step 4: Upgrade the Setup

After removing the sample data, you need to upgrade the setup by running:

Run
php bin/magento setup:upgrade

Step 5: Clear the Cache

Finally, clear the cache to ensure that the changes take effect:

Run
php bin/magento cache:clean

Conclusion

And that’s it! You have successfully removed sample data from your Magento 2 installation. Now your Magento 2 is ready for production use. Remember, always backup your data before making any major changes to your system.

You may also like :

Create CMS Block Programmatically Magento 2

Patch to Debug Blocks and Containers in Magento 2

How to validate email address in Magento 2 programmatically?

People also search for :

  • How to remove sample data from magento 2
  • Magento sample data
  • Magento 2 xml remove block
  • Magento 2 remove sample data from database
  • Magento 2 remove sample data
  • Remove sample data magento 2
  • Magento 2 sample data

Written by Jigar Karangiya, Adobe Commerce & Magento 2 developer.

More about me

Related posts