Magento takes default database port to 3306. In case of the port 3306 used by any other application and mySQL is running on another port then we can use that new port by passing port number with the database host.
--db:host=127.0.0.1:3307
Here 3307 is a port which bind with the MySQL.
So, a full command will be to install the Magento:
php bin/magento setup:install \
--base-url=https://magento244.test \
--db-host=127.0.0.1:3307 \
--db-name=magento2 \
--db-user=root \
--db-password=root \
--admin-firstname=Mage \
--admin-lastname=Smoker \
[email protected] \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1 \
--search-engine=elasticsearch7 \
--elasticsearch-host=es-host.example.com \
--elasticsearch-port=9200 \
--elasticsearch-index-prefix=magento2 \
--elasticsearch-timeout=15
If you getting error to run above command then you can put in a single line and install to:
php bin/magento setup:install --base-url=https://magento244.test --db-host=127.0.0.1:3307 --db-name=magento2 --db-user=root --db-password=root --admin-firstname=Mage --admin-lastname=Smoker [email protected] --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1 --search-engine=elasticsearch7 --elasticsearch-host=es-host.example.com --elasticsearch-port=9200 --elasticsearch-index-prefix=magento2 --elasticsearch-timeout=15