Ville Miekk-oja
Ville Miekk-oja

Reputation: 21035

MongoDB: How to find the exact version of installed MongoDB

I have mongoDB 3.2 installed locally for Windows 7. I would like to find out its specific version (like is it 3.2.1, or 3.2.3 or...). How could I find it? If I open the database shell (mongo.exe), I can see it outputs:

MongoDB shell version: 3.2.0

But that's just the shell version, and I'm not sure whether it's the same as my real database version.

Upvotes: 253

Views: 459221

Answers (8)

Anandela
Anandela

Reputation: 21

C:\Program Files\MongoDB\Server\6.0\bin\mongod.exe" --version

just run in cmd adjust it your path

Upvotes: 0

Rehan
Rehan

Reputation: 55

For Mac users try running this command

brew services start mongodb-community

Upvotes: -4

Saurabh Mistry
Saurabh Mistry

Reputation: 13689

mongo --version

MongoDB shell version: 2.6.10

mongod --version

db version v2.6.10

mongo

MongoDB shell version: 2.6.10
connecting to: test

db.version()

2.6.10

Upvotes: 15

tarun kumar143
tarun kumar143

Reputation: 441

To check MongoDB version use the mongod command with --version option.

To check the MongoDB Server version, Open the command line via your terminal program and execute the following command:

Path: C:\Program Files\MongoDB\Server\3.2\bin
Open Cmd and execute the following command:
mongod --version
To Check MongoDB Shell version:
mongo --version

Upvotes: 23

Kalyan Halder
Kalyan Halder

Reputation: 1585

Sometimes you need to see version of mongodb after making a connection from your project/application/code. In this case you can follow like this:

 mongoose.connect(
    encodeURI(DB_URL), {
      keepAlive: true
    },
    (err) => {
      if (err) {
        console.log(err)
      }else{
           const con = new mongoose.mongo.Admin(mongoose.connection.db)
              con.buildInfo( (err, db) => {
              if(err){
                throw err
              }
             // see the db version
             console.log(db.version)
            })
      }
    }
  )

Hope this will be helpful for someone.

Upvotes: 1

Paul Jackson
Paul Jackson

Reputation: 2147

From the Java API:

Document result = mongoDatabase.runCommand(new Document("buildInfo", 1));
String version = (String) result.get("version");
List<Integer> versionArray = (List<Integer>) result.get("versionArray");

Upvotes: 4

Option1:

Start the console and execute this:

db.version()

Option2:

Open a shell console and do:

$ mongod --version

It will show you something like

$ mongod --version
db version v3.0.2

Upvotes: 181

Punit Gupta
Punit Gupta

Reputation: 4398

Just run your console and type:

db.version()

https://docs.mongodb.com/manual/reference/method/db.version/

Upvotes: 390

Related Questions