Sometimes, we may face issues for which we might need to look for the version of the software we are on like Which MongoDB version do I have ? So, here in this article we will see many different methods to check the version of the MongoDB instance that we are working on. So what are we waiting for ?? Lets take a quick sneak peek into it.

The db.version() method — To check Which MongoDB version do I have

If you’re already connect to Mongo database, you’ll use the db.version() method to see the version. It returns the instance version that we are working on presently.

db.version()

# Result:
4.4.2

The mongod –version method

If you’re not connect to MongoDB, you’ll open a Terminal window or prompt and run mongod –version command to check the same.

mongod --version

# Result:
db version v4.4.2
Build Info: {
"version": "4.4.2",
"gitVersion": "ad91a93a5a31r245f5cbf8c69561e788bbc55ce1",
"modules": [],
"allocator": "system",
"environment": {
"distarch": "x86_64",
"target_arch": "x86_64"
}
}
Which MongoDB version do I have

Using the mongo –help method

If the above commands are not in your mind. You can use another way to check for the mongo shell version. This is by running the mongo –help from a Terminal window or prompt.

mongo --help

# Result:
MongoDB shell version v4.4.2

The mongo method — Another method to check Which MongoDB version do I have

Simply connecting to Mongo database via the mongo shell will end in both the mongo shell edition and therefore the MongoDB server edition being on show. For example, opening a Terminal window or prompt , and entering the subsequent command, connects to MongoDB:

mongo

Once it connects, you ought to see something like this:

MongoDB shell version v4.4.2
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("8f56a0d8-7079-4884-bf2c-6a67b832d1a9") }
MongoDB server version: 4.4.2
Welcome to the MongoDB shell.
…

The mongo –version method

If you would like the mongo shell version, you’ll run the mongo –version command from a Terminal window or prompt. This will fetch the version of the MongoDB shell.

mongo --version

# Result:
MongoDB shell version v4.4.2
Build Info: {
"version": "4.4.2",
"gitVersion": "ad91a93a5a31r245f5cbf8c69561e788bbc55ce1",
"modules": [],
"allocator": "system",
"environment": {
"distarch": "x86_64",
"target_arch": "x86_64"
}
}
Which MongoDB version do I have

Here’s the place to your complete MongoDB solutions…..

Checking by using the buildinfo method

The “buildInfo” command checks the build summary of the MongoDB instance we are presently using or working on.

db.runCommand( { buildInfo: 1 } )

# Result:
{
"version" : "4.4.2",
"gitVersion" : "ad91a93a5a31r245f5cbf8c69561e788bbc55ce1",
"modules" : [ ],
"allocator" : "system",
"javascriptEngine" : "mozjs",
"sysInfo" : "deprecated",
"versionArray" : [4,
4,
2,
0
],
…
}

MongoDB Compass GUI — Which MongoDB version do I have

If you employ MongoDB Compass, you’ll find the MongoDB edition listed within the sidebar.

By visiting the Windows Control Panel

If your MongoDB database is on a Windows OS, you can find details about the same in the Control Panel.

  • You just need to go to the Control Panel from the Windows Start Menu.
  • After that, visit the Programs and Features section.
  • Then, proceed to check for the MongoDB DBMS.
  • You will find the edition of the software written in the right hand side of the row mentioning the MongoDB instance and the installation date.
Which MongoDB version do I have

SUMMARIZING — Which MongoDB version do I have

In this post, we have gone through a number of methods to check for the MongoDB edition we have or we are using. We have seen various commands that come in handy in this regard and also various other tricks. You can use any command or trick that suits you and there is no hard and fast rule for the same.

Categorized in: