How to find the exact version of installed MongoDB

后端 未结 5 1866
独厮守ぢ
独厮守ぢ 2021-01-31 01:04

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

5条回答
  •  灰色年华
    2021-01-31 01:25

    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.

提交回复
热议问题