How To Install Sample Data In Magento 2 in 2024

June 29, 2016 Written By Yogesh Trivedi

Talk to Experts Need expert help? Don’t hesitate to talk.

You can do direct email atinfo@mconnectmedia.com

WE'RE HERE FOR YOU

We would love to hear about your Magento project, challenge, or opportunity. We'll respond within 24 hours!

It’s been a question all around that things are not easy to be performed on Magento 2 as it comes most with the command line management and this require great knowledge of CLI commands.

Also when it comes to sample data installation on Magento 2, it’s not so easy to do because it involves direct access to Magento repo and packages in order to download sample data using command line where you need access key for authentication.  Our Magento Experts clearly know how to perform the installation of sample data with CLI commands. In case you come up with any query from the contents below, you can get in touch with our Experts.

Here is how it can be done step by step:

I saw few of the commands on an internet that how we can run Magento inbuilt command especially for deploying and installing sample data.

Magento 2 facilitate inbuilt CLI application structure to run command via bin/Magento in
Bin folder located under the root directory of Magento 2.

To run Magento commands from any directory, add <your Magento install dir>/bin to your system PATH.

So in the case to install sample data, the following process needs to be followed.
First open your command line: either terminal, putty or command prompt
Copy your Magento folder path: cd /var/www/html/magento/

Start on installing sample data:
php bin/magento sampledata:deploy

This command will call Magento repository from repo.magento.com/json.packages but in order to access this you need to be authenticated with Magento marketplace account.

It will ask you for user name and password, here is how you will get your user and password in defined way:

  • Go to Magento Marketplace – marketplace.magento.com
  • Access to your My Account Page
  • From there go to My Access Keys under My products, you will prompt to next window.
  • From My Access Key window you will see an button in bottom to Generate new, if you done see any Name and Keys, click on Generate New button with inserting any name there.

Step-by-Step Guide for Executing Tasks on the Provided Window

  • If you already have keys, use the Public key as your user name and the Private key as your password.
  • New key: In the Name field, enter a name to identify the keys and click Generate new.
  • You can optionally generate additional keys; for example, to provide access to repo.magento.com to co-workers, contractors, or integrator.
  • Regenerate or rename existing keys: Click Regenerate.
  • You can regenerate your keys for security reasons; for example, you believe they have been compromised.
  • Save an existing key if you changed its name: Click Save.
  • Disable keys: Click Disable. You can do this if you want to suspend use of your keys.
  • Delete keys: Click Delete.

Now you will get couple of keys in form of, check screenshot.

  • Public Key
  • Private Key

My Aceess Key Window

Now here is the perk: in command line you need to use Public Key as user name and Private Key as password, its bit strange but this is how it works.

Now command line automatically prompt to download sample data from repository but before that it will ask you if you want system to remember the access keys for next use – (y)yes/(n)no, if you select yes it will not ask you for user and password in next attempt to access Magento repo if no then it will ask every time till you select yes.

In case you see and memory exhausted error, to resolve this either you can set limit in php.ini – search for memory_limit, by default it will be 128M, just increase it to 512M

Restart your apache/nginx server, in case window restart your wamp/xampp server.

Run the command again php bin/magento sampledata:deploy
In case if again it throw the memory limit error then this is the welcome solution where you can run this using below command:

php -dmemory_limit=2G bin/magento setup:static-content:deploy

-dmemory_limit=2G that means it will only set limit on fly when you run this command.

You can assign any value 2GB or as you want depending on the memory you have in your system.

This time you will get your sample data deployed…

Here are few more magento predefined commands to perform stuffs in commandline:

setup:install
Install Magento 2 directly from commandline

theme:uninstall
you can use this to uninstall the them you want to remove from store

i18n:uninstall
This command used to uninstall language packages

setup:uninstall
You can uninstall Magento using this command

module:uninstall
Uninstall any module you want utilizing this commandline.

sampledata:reset
Reset your sample date with this command

sampledata:remove
You can remove sample data using this remove command

sampledata:deploy
Deploy and install sample data on your Magento store.

Still have some confusion regarding the installation of sample data on Magento 2.0? Then don’t hesitate in writing to our Magento Support. We will be really delighted to help you!

Need Magento expert help?

We provide result-driven solutions to expand the competency level and productivity.

Instant Help CenterAvailable!

Monday to FridayResponse promised within 24 hours!

Call Us

+1 319 804-8627

Multiply Your Customers with Magento 2.0 Out of Stock Notification Extension

2 comments

  1. Thank you for sharing the Installation process of sample data using CLI command, step by step. This is really helpful!

  2. Hello Yogesh! Thanks for providing the step wise tutorial for the installation of Sample data using the CLI command in Magento 2. I have followed the steps provided in the blog post and it is working fine on my store.

Load Comments

Your email address will not be published. Required fields are marked *

5 4 3 2 1

  • Worried for deadlines? Our Magento Experts are effortlessly Working from Home.
  • Check out our Magento Developer Hiring Packages for Agency as well as individuals.
View Packages

Talk to Experts Need expert help? Don’t hesitate to talk.

You can do direct email atinfo@mconnectmedia.com

WE'RE HERE FOR YOU

We would love to hear about your Magento project, challenge, or opportunity. We'll respond within 24 hours!

Please fill this form, Mr.Yogesh will reply by email asap.


Please fill this form, Mr.Darshit will reply by email asap.


Please fill this form, Mr.Jayesh will reply by email asap.


Please fill this form, Mr.Jiten will reply by email asap.