How to Set System Configuration Value Using CLI Command in Magento 2
Magento 2 CMS provides the powerful command-line interface tool that allows the developers to use default commands that perform tasks including installation, modules, indexes management, database backups-updates, compiling LESS, etc.
Moreover, it also provides an excellent feature that allows the developer to set system configuration value using CLI command in Magento 2! You can set Magento 2 default configuration option value as well as third-party extension configuration value from the CLI command.
To do so, you’ll require the value of:
- The configuration path
- The scope code
- Log in to your account using SSH.
The scope code is needed to set a configuration value for a particular scope, and one can find the configuration path from the ‘core_config_data’ table of the database.
To make this explanation more specific, let’s consider an example.
For instance, the admin panel of Magento 2 is not working or opening for any reason. Somehow you have to change the value of the system configuration. In that case, you have to find out a way that can change or set a system configuration value without opening the admin panel!
For such a scenario, use the below method and validate an appropriate value in the CLI command.
Method to Set System Configuration Value Using CLI Command in Magento 2
Pass CLI commands:
bin/magento config:set [config/path/here] [value]
bin/magento config:set web/secure/base_url https://domain.com/
Set Website Wise System Configuration Value:
bin/magento config:set --scope=websites --scope-code=base web/secure/base_url https://domain.com/
Set Store Wise System Configuration Value:
bin/magento config:set --scope=stores --scope-code=default web/secure/base_url https://domain.com/
Any doubts about this solution can be mentioned in the Comments section below.
I’d be happy to help.
Also, do share the post with Magento Community via social media.