Docs Menu

Restrict Write Operations to MongoDB

You can use the readOnly option to prevent users from performing write operations to your MongoDB deployment through Compass. If you enable the readOnly option, users cannot modify documents, create indexes, or specify validation rules.

By default, Compass disables the readOnly option.

If the readOnly option is enabled, you cannot enable the following options:

You can enable the readOnly option in either:

1
Settings gear icon location on MongoDB Compass UI

Alternatively, you can use keyboard shortcuts to open the Settings panel:

  • Windows / Linux: Ctrl + ,

  • Mac: + ,

Compass opens a dialog box where you can configure your MongoDB Compass settings.

2
3

The following command starts Compass from the command line and sets the --readOnly option:

<path-to-Compass-executable> --readOnly

Note

The name and filepath of the Compass executable depend on your operating system.

You can specify the Compass configuration file in either EJSON or YAML format. The following configurations set the readOnly option to true:

{ "readOnly": true }
readOnly: true

To learn more about the MongoDB Compass configuration file, see Configuration File Settings.