There are a number of command-line switches associated with the mongo shell (https://docs.mongodb.com/manual/mongo/#the-mongo-shell), the most important of which are summarized here. You should note that the mongo shell is used to connect to a mongod server instance, which is typically running as a system daemon or service.
The following table presents a summary of the more important mongo shell command-line switches:
Option | Example | Notes |
--port | mongo --port 28888 | Lets you connect to a mongod instance that uses a non-default port. Note that the port can also be specified when using the --host flag (described next). |
--host | mongo --host 192.168.2.57:27017 mongo --host mongo.unlikelysource.net |
This option lets you connect to a mongod instance running on another server. :port is optional. If left off, the port value defaults to 27017. |
--username --password |
mongo --username doug --password 12345 | Connects to a mongod instance as an authenticated... |