Magento 2 Install / Uninstall Sample Data via Command Line
In this tutorial, we will talk about Install / Uninstall Sample Data via Command Line in Command Line Series. As you know, from Magento 2, they add many commands in bin/magento
. If you find it quite hard to understand this, I will try to make it easier for you to understand by the instructions to install and uninstall sample data via command lines.
Let’s start!
Install / Uninstall Sample Data via command line
Go to Magento admin root folder and show usages:
php bin/magento maintenance:enable
Result:
Usage:
sampledata:deploy [options]
Options:
--no-update Update composer.json without executing composer update
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
Deploy sample data modules
Install Sample Data Syntax
php bin/magento sampledata:deploy [options]
By default, it will update latest version of sample data via composer, then install it.
You can disable it with parameter: --no-update
php bin/magento sampledata:deploy --no-update
Magento asks me enter Username and password like this:
Don’t worry, Go to Access Keys page and Create A New Access Key
Output:
Uninstall Sample Data Syntax
Go to Magento admin root folder and show usages:
php bin/magento sampledata:remove -h
Output:
Usage:
sampledata:remove [options]
Options:
--no-update Update composer.json without executing composer update
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
Remove all sample data packages from composer.json
Syntax:
php bin/magento sampledata:remove [options]
Wrap up
That’s how you can easily install and uninstall sample data via command lines in Magento 2. I hope this tutorial is helpful for you. If you have any questions, please let me know. Thanks for reading!
Enjoyed the tutorial? Spread it to your friends!
Sam Thomas>Haley
CEO and Founder of Mageplaza. Pursueing a simple and healthy lifestyle. A friend, a husband and a dad of two children, a trainer and an influencer wannabe. He is a big fan of sports and travel, also.