Connecting to MongoDB Server Instance Using the Mongo Shell

The Mongo Shell is an interactive JavaScript interface to MongoDB. You can use the mongo shell to query and update data as well as perform administrative operations ( https://docs.mongodb.com/manual/mongo/ ).

Selecting to install client tools along with MongoDB Server, installs the Mongo Shell along with the server install.

If left with default installation folder, mongo.exe can be found under:

“C:\Program Files\MongoDB\Server\4.2\bin\mongo.exe”

We could add this path to our %PATH% environment variable to avoid fully qualifying the path to the mongo.exe command.

Note that by default Mongo Client Shell attempts to connect to 127.0.0.1 and port 27017.

If the MongoDB Server is configured to listen at a different IP address, a command line option “–host” needs to be supplied accordingly.

“C:\Program Files\MongoDB\Server\4.2\bin\mongo.exe” –host <new_ip_address>

We have a few options when changing the default IP (127.0.0.1) that MongoDB Server listens on. We can specify the IP as a command line switch to mongod.exe or change it in the server configuration file (mongod.cfg) in the section shown below. Note that binding to  “0.0.0.0”  would have the MongoDB Server listen on all available server IP addresses.