Using brew upgrade Mongo update from 3.4 to 4.0 error: The data files need to be fully upgraded to version 3.6 before attempting an upgrade to 4.0

I need to downgrade MongoDB to 3.4. Clean up all the versions. Then upgrade to 3.6 and 4.0 step by step.

First of all, back up your /data/db, just in case.

The following steps are from my experience, I used brew to install/uninstall mongodb.

I followed the instruction from this thread, but run the following steps on iMac.

Error while upgrading Mongodb from 3.2 to 3.6

Uninstall your current mongodb

brew uninstall mongodb

Install mongodb 3.4 version

brew install [email protected]

Start mongod 3.4 version (when you install the old version like above, you need the full path to run it.)

/usr/local/opt/[email protected]/bin/mongod

Start mongo 3.4 version

/usr/local/opt/[email protected]/bin/mongo

Run the important command

> db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )

Quit

>quit();

Terminate the mongod

Find PID of mongod process using $ top

Kill the process by $ kill <PID> (the Mongo docs have more info on this)

Uninstall mongodb 3.4

brew uninstall [email protected]

Repeat the above steps for 3.6

Install mongodb 3.6 version

brew install [email protected]

Start mongod 3.6 version

/usr/local/opt/[email protected]/bin/mongod

Start mongo 3.6 version

/usr/local/opt/[email protected]/bin/mongo

Run the important command

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

...

Last, after uninstall 3.6, then you can install the most current version, 4.x, you don't have to specify the @4.x etc., just

Install the most current version

brew install mongodb

Tags:

Mongodb