In Case You Cannot Access The Admin
If like me you could not access the admin in order to make the required change then on top of Amit Bera's answer, you will need to add a core_config_data
configuration with the path:
INSERT INTO `core_config_data`(`scope`, `scope_id`, `path`, `value`)
VALUES(
'default', #-- Or whatever your Scope is
0, #-- Or whatever your Scope ID is
'admin/url/use_custom',
1
);
INSERT INTO `core_config_data`(`scope`, `scope_id`, `path`, `value`)
VALUES(
'default', #-- Or whatever your Scope is
0, #-- Or whatever your Scope ID is
'admin/url/custom',
'https://my.url.com/newadminpath/'
);
Then run the CLI command:
php bin/magento setup:config:set --backend-frontname="newadminpath"
php bin/magento maintenance:enable
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento maintenance:disable