Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This version of MongoDB is too recent to start up on the existing data files. Try MongoDB 4.2 or earlier

Tags:

linux

mongodb

I recently updated my mongodb version to 4.4 from 4.2. Seems like it had some breaking changes.

Now the service is not at all running, and showing me this error.

I know downgrading is not an option. But is there a solution to this?

Thanks in advance

like image 315
Jithin Avatar asked Sep 30 '20 15:09

Jithin


3 Answers

You first need to upgrade your database to version 4.2 before using mongodb 4.4.

It is not directly obvious from the official guides related to migration but mongodb do not automatically update the version of a database to match the version of the mongodb program.

Actually it will try to keep compatibility with the version used when creating the database. You need to do one manual operation to tell mongodb to update the format of the database.

Mongodb releases tends to understand format used by the previous version but not older (so mongo 4.4 can use database in versions 4.2 but not earlier).

So the solution is to first start a mongodb instance compatible with the version of the database (4.2 in your case) and use the mongo client to issue this command:

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

This will actually ask mongodb to migrate the format of the database to use version 4.2.

Now, you can use the release 4.4 of mongoDB but it will use your database in a compatibility mode with the version 4.2.

You can directly issue the next command to apply the migration right away.

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

These operations are required for each release of MongoDB. So, if you happen to have a database that is several release behind, you have to manually update it through each and every version of MongoDB.

like image 116
Nicolas Dusart Avatar answered Oct 18 '22 03:10

Nicolas Dusart


I got the solution, but it's a hard one.

i deleted everything inside /data/db were I kept all my mongoose data.

I backed up the data for now, but didn't get a correct solution

like image 37
Jithin Avatar answered Oct 18 '22 01:10

Jithin


You must upgrade MongoDB one release at a time. See https://docs.mongodb.com/manual/release-notes/4.4-upgrade-standalone/ and https://docs.mongodb.com/manual/release-notes/4.2/#upgrade.

Complete the upgrade to 4.2 then upgrade to 4.4.

like image 40
D. SM Avatar answered Oct 18 '22 03:10

D. SM