How do I know which MongoDB version is installed using the Command Line?

To check which MongoDB version is installed on your system, you can use the command line to query the MongoDB server directly. This is useful for verifying your installation and ensuring compatibility with your applications.

Syntax

mongo --version

Or alternatively:

mongod --version

Method 1: Using mongo --version

Open your command prompt and navigate to the MongoDB bin directory. Then execute the following command ?

mongo --version
MongoDB shell version v4.0.5
git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
OpenSSL version: OpenSSL 1.1.0i  14 Aug 2018
allocator: tcmalloc
modules: none
build environment:
    distmod: 2008plus-ssl
    distarch: x86_64
    target_arch: x86_64

Method 2: Using mongod --version

You can also check the MongoDB daemon version using ?

mongod --version
db version v4.0.5
git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
OpenSSL version: OpenSSL 1.1.0i  14 Aug 2018
allocator: tcmalloc
modules: none
build environment:
    distmod: 2008plus-ssl
    distarch: x86_64
    target_arch: x86_64

Method 3: From MongoDB Shell

If you're already connected to the MongoDB shell, you can use ?

db.version()
4.0.5

Key Points

  • The mongo --version command shows the MongoDB shell version
  • The mongod --version command shows the MongoDB server daemon version
  • Both commands provide detailed build information including git version and OpenSSL details
  • The db.version() method works only when connected to a MongoDB instance

Conclusion

Use mongo --version or mongod --version from the command line to quickly check your MongoDB version. These commands provide comprehensive version information including build details and dependencies.

Updated on: 2026-03-15T00:54:50+05:30

12K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements