Docs Menu

Docs HomeView & Analyze DataMongoDB Compass

Restrict Write Operations to MongoDB

On this page

  • About This Task
  • Procedure
  • Compass Settings Panel
  • Command Line
  • Configuration File
  • Learn More

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 panel location under the MongoDB Compass system menu

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

  • Windows / Linux: Ctrl + ,

  • Mac: + ,

2

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

3
4

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.

← Hide Credentials in Your Connection String