How to Set the featureCompatibilityVersion in MongoDB

In MongoDB, the setFeatureCompatibilityVersion command enables or disables the features that persist data incompatible with earlier versions of MongoDB.

Syntax

The syntax goes like this:

db.adminCommand( { setFeatureCompatibilityVersion: <version> } )

Where <version> is the version that you want to set it to.

Example

Here’s an example to demonstrate the setFeatureCompatibilityVersion command:

db.adminCommand( { setFeatureCompatibilityVersion: "4.4" } )

You need to run this against the admin database.

View the Current Setting

The setFeatureCompatibilityVersion is the same setting that you can view with the featureCompatibilityVersion command.

For new MongoDB deployments, the featureCompatibilityVersion is usually the same as that version. For example, my MongoDB 4.4.1 instance returns a featureCompatibilityVersion of 4.4.

When you upgrade to a new version of MongoDB, your featureCompatibilityVersion will typically remain at its original value until you explicitly upgrade it with setFeatureCompatibilityVersion.

MongoDB Documentation

For more information, see the MongoDB documentation.