Here are some common command line options (https://docs.mongodb.com/manual/reference/program/mongo/#options) when invoking mongo:
- mongo: Opens up the interactive command shell.
- mongo -u username -p password -h host --port nnnn --ssl: The first two options are needed when security has been configured. The next two options are needed when accessing a remote MongoDB instance. The last option secures the command stream using TLS or SSL. Also, refer to the Chapter 7, Securing MongoDB, in this book for more information on setting up TLS/SSL.
- mongo some_JavaScript_file.js: Executes a JavaScript file containing MongoDB commands.
- mongo --eval 'JavaScript': Directly runs the JavaScript commands in quotes.
- mongo --help ...