.mongorc.js File

All command line option flags can be coded into a file, mongorc.js (https://docs.mongodb.com/manual/reference/program/mongo/#files). When you run the mongo command, this file is parsed unless you include the command line switch mongo --norc. There are two primary locations for this file; the user home directory, or the operating system's /etc directory:

It is very important to set the rights properly if using /etc/mongorc.js. Otherwise, you will receive a permissions error when the mongo shell first starts. The recommended rights would be to assign ownership to the user mongodb, and read + execute rights to all others.

Here ...

Get MongoDB 4 Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.