Downgrade 4.0 Standalone to 3.6

Before you attempt any downgrade, familiarize yourself with the contentof this document.

Downgrade Path

Once upgraded to 4.0, if you need to downgrade, we recommend downgrading to the latest patch release of 3.6.

Create Backup

Optional but Recommended. Create a backup of your database.

Prerequisites

Before downgrading the binaries, you must downgrade the featurecompatibility version and remove any 4.0 featuresincompatible with 3.6versions as outlined below. These steps are necessary only iffeatureCompatibilityVersion has ever been set to "4.0".

1. Downgrade Feature Compatibility Version

  • Connect a mongo shell to the mongod instance.

  • Downgrade the featureCompatibilityVersion to "3.6".

  1. db.adminCommand({setFeatureCompatibilityVersion: "3.6"})

The setFeatureCompatibilityVersion command performs writesto an internal system collection and is idempotent. If for any reasonthe command does not complete successfully, retry the command on themongod instance.

2. Remove Backwards Incompatible Persisted Features

Remove all persisted features that are incompatible with 4.0. For example, if you have definedany view definitions, document validators, and partial index filtersthat use 4.0 query features such as the aggregation convertoperators, you must remove them.

If you have users with only SCRAM-SHA-256 credentials, you shouldcreate SCRAM-SHA-1 credentials for these users before downgrading.To update a user who only has SCRAM-SHA-256 credentials, rundb.updateUser() with mechanisms set to SCRAM-SHA-1only and the pwd set to the password:

  1. db.updateUser(
  2. "reportUser256",
  3. {
  4. mechanisms: [ "SCRAM-SHA-1" ],
  5. pwd: <newpwd>
  6. }
  7. )

Procedure

Note

If you ran MongoDB 4.0 with authenticationMechanismsthat included SCRAM-SHA-256, omit SCRAM-SHA-256 whenrestarting with the 3.6 binary.

Download the latest 3.6 binaries.

Using either a package manager or a manual download, get the latestrelease in the 3.6 series. If using a package manager, add a newrepository for the 3.6 binaries, then perform the actual downgradeprocess.

Once upgraded to 4.0, if you need to downgrade, we recommend downgrading to the latest patch release of 3.6.

Restart with the latest 3.6 mongod instance.

Shut down your mongod instance. Replace the existingbinary with the downloaded mongod binary and restart.