October 13, 2022
How to install Magento 2 sample data

Magento is a powerful ecommerce platform.

But learning how to use Magento correctly can be challenging. To simplify this task, Adobe provides a sample data module for Magento 2 that transforms a Magento installation into a demo Magento 2 store.

This guide explains the basics of the Magento 2 sample data module and teaches you how to install it correctly.

Here’s what we cover in this tutorial:

Magento 2 sample data 101

Magento sample data is a module that transforms a Magento instance into a demo store. That store comes with sample data such as customers, orders, categories, CMS pages, and pricing rules. Besides that, it installs the free Luma Magento 2 theme and adds over 250 Magento 2 products.

The sample data module is a collection of 19 packages for Magento Open Source and 24 packages for Adobe Commerce.

You can view the packages for Magento Open Source inside the sample data repository.

Adobe Commerce users get access to those packages plus the following five modules for Commerce-specific features:

  • magento/module-target-rule-sample-data.
  • magento/module-customer-balance-sample-data.
  • magento/module-gift-registry-sample-data.
  • magento/module-gift-card-sample-data.
  • magento/module-multiple-wishlist-sample-data.

You can install Magento sample data in three ways:

  1. Using the Magento Command Line Interface (CLI).
  2. Using Composer.
  3. By cloning the Magento GitHub repository.

The Magento CLI and Composer installation methods can be used when you’ve installed Magento 2 using an archive file from Adobe or a Composer metapackage.

But those methods won’t work if you’ve installed Magento by cloning its GitHub archive.

That’s because the composer.json file in the GitHub archive doesn’t contain the “https://repo.magento.com” URL. If you’ve installed Magento 2 by cloning a GitHub archive, you’ll need to install sample data by cloning its GitHub repository.

Adobe provides you with the sampledata:remove CLI command to uninstall sample data modules. However, that command doesn’t delete Magento database entries.

The only way to remove the Magento 2 sample data module entirely is by dropping the database and reinstalling Magento 2 with a new database.

Get fully managed Magento hosting

Accelerate your store's potential, without the tedious maintenance

How to install sample data in Magento

  1. Log in to your server and enable developer mode.
  2. Execute the sample data installation command.
  3. Update the database and schema and clear the Magento cache.
  4. Verify the sample data installation.

Follow these steps to install sample data in Magento 2.

Note: Do not install sample data on a production server, as you cannot uninstall the module without deleting the Magento database and reinstalling Magento.

Step 1: log in to your server and enable developer mode

Log in to your server over SSH, switch to the Magento file system user, and navigate to the Magento root directory. Then, enable developer mode using:

$ php bin/magento deploy:mode:set developer


Then, clear previously generated classes and proxies using the following command:

$ rm -rf generated/code/* generated/metadata/*

Step 2: execute the sample data installation command

Install the Magento 2 sample data module using the following command:

$ php bin/magento sampledata:deploy


You should see the following terminal output:

Magento 2 sample data installation.

Note: You may need to enter your Magento authentication keys at this point. Follow Adobe’s guide to retrieve the public and private keys used to install your Magento application and use the same keys for the sample data module installation.

Step 3: update the database and schema and clear the Magento cache

Once the Magento 2 sample data installation command executes successfully, update the Magento database and schema using the below command:

$ php bin/magento setup:upgrade

After that, clear all Magento cache types using:

$ php bin/magento cache:clean
$ php bin/magento cache:flush

Upgrade the Magento database and clear the cache.

Step 4: Verify the sample data installation

Finally, access your storefront in a browser. Here’s how it will look:

Magento 2 sample data homepage design.

Common Magento sample data installation errors & steps to fix them

Here are three common errors you might encounter during sample data installation and the steps to fix them.

1. File system permissions error

File system permission errors are one of the most common errors you might face when you install Magento 2 sample data.

For instance, you might encounter exceptions such as:

  • Can’t create directory /var/www/html/magento2/generated/code/Magento/CatalogRule/Model/.
  • Class Magento\CatalogRule\Model\RuleFactory does not exist.

If you face such errors, you’ll need to reset file system permissions based on your deployment.

Follow Adobe’s guide demonstrating the steps to set file system access permissions and rerun the sampledata:deploy command.

2. Magento mode error

Installing Magento sample data in production mode can cause a PHP Fatal error or the following error when you run the setup:upgrade command:

Production mode error Magento 2 sample data installation.

To prevent such errors, switch to developer mode and clear generated data before you install Magento 2 sample data.

3. PHP max_execution_time error

The Magento sample data module installation process is a resource-intensive task. Depending on your server configuration, it can take anywhere from a few seconds to several minutes.

Sometimes, it can fail silently when the max_execution_time in your PHP configuration file is inadequate for the sample data script.

To fix this issue, switch to a user with root privileges and edit the php.ini file using your preferred text editor.

For instance, if your PHP version is 7.4, you can run this code:

$ nano /etc/php/7.4/fpm/php.ini

Find the max_execution_time setting and update its value to 600 or more. Save the file and restart PHP to update its configuration.

After that, run the sampledata:deploy command and reset the max_execution_time value to the original value once the Magento 2 sample data installation is completed.

Final thoughts: how to install Magento 2 sample data

We’ve explained the basics of the Magento 2 sample data module, demonstrated a step-by-step installation process, and shared tips to fix common errors.

It’s important to remember that you can’t uninstall sample data without reinstalling Magento. So make sure you only install it in a staging environment.

Don’t have a test server?

Sign up for managed Magento hosting with Nexcess and get access to dedicated staging sites at no extra cost.

Browse our plans to learn more.

Maddy Osman
Maddy Osman

Maddy Osman is a WordPress expert, WordCamp US speaker, bestselling author, and the Founder and SEO Content Strategist at The Blogsmith. She has a B.A. in Marketing from the University of Iowa and is a WordCamp Denver organizer while also operating The Blogsmith, an SEO content agency for B2B tech companies that works with clients like HubSpot, Automattic, and Sprout Social. Learn more about The Blogsmith's process and get in touch to talk content strategy: www.TheBlogsmith.com

We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.