Magento 2 : How To Install Sample Data using CLI Command ?

Please fill this form, We'll reply within 24 Hrs.


Install Sample data on Magento 2 using CLI Commands

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.

Here is process one by one on the given 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!

Multiply Your Customers with Magento 2.0 Out of Stock Notification Extension
Magento 2 Index Management

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.

Leave a Reply

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

Please fill this form, We'll reply within 24 Hrs.


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.


Free eGuide

Ultimate Guide on Magento 2 Shipping Methods

Shipping Methods also play a very vital role in an eCommerce store, to make it a success.
DOWNLOAD NOW