Open In App

How to Find the Exact Version of Installed MongoDB

Last Updated : 26 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Determining the version of MongoDB installed on our system is a fundamental task, whether we are developers, database administrators or system administrators. Knowing the MongoDB version is essential for compatibility testing, troubleshooting, and ensuring we are using the latest features and security areas.

In this article, we’ll explore various methods to find the exact version of installed MongoDB on different platforms, providing detailed examples and outputs to guide beginners through the process effectively.

How to Find the Exact Version of Installed MongoDB?

MongoDB follows a versioning scheme that consists of major, minor, and patch versions. The version number typically appears in the format of major, minor, patch, where:

1. Major Version

  • A major version in MongoDB signifies significant changes to the software that may include breaking changes or major feature additions.
  • Breaking changes are modifications to the software that are not backward-compatible, meaning they may cause existing applications or integrations to fail.
  • Major feature additions introduce new functionality or capabilities that significantly enhance the software.

2. Minor Version

  • A minor version indicates incremental improvements, feature enhancements, or bug fixes to the software. These updates typically introduce new features or improvements to existing features without making significant changes to the software’s overall architecture.
  • Minor versions may also include bug fixes to address issues identified in previous versions. Upgrading to a new minor version is generally less disruptive than upgrading to a new major version but still requires testing to ensure compatibility

3. Patch Version

  • A patch version denotes minor updates or bug fixes that address specific issues or vulnerabilities in the software. Patch versions are typically released more frequently than minor or major versions and are intended to provide immediate fixes for critical problems.
  • Patch versions do not usually introduce new features or make significant changes to the software’s functionality. Upgrading to a new patch version is generally straightforward and is recommended to ensure the security and stability of the software.

Ways to Find the Exact Version of Installed MongoDB

1. Using the MongoDB Shell

The MongoDB shell provides a built-in command to retrieve the server version.

  • Open a terminal or command prompt.
  • Start the MongoDB server if it is not already running.
  • Run the mongo command to open the MongoDB shell.
  • Run the db.version() command to display the MongoDB server version.

Example:

$ mongo
> db.version()

Output:

4.4.12

2. Using the mongod Command

We can also retrieve the MongoDB version by running the mongod command with the –version option.

Example:

$ mongod --version

Output:

db version v4.4.12
Build Info: {
"version": "4.4.12",
"gitVersion": "4d5ff2e198b903753ebad165ab6baf46154dfebe",
"modules": [],
"allocator": "tcmalloc",
"environment": {
"distmod": "ubuntu2004",
"distarch": "x86_64",
"target_arch": "x86_64"
}
}

3. Checking Package Manager Information

If we installed MongoDB using a package manager such as APT (for Debian/Ubuntu) or YUM (for CentOS/RHEL), we can use the package manager to query information about the installed MongoDB package.

Example (APT):

$ apt show mongodb-org

Output:

Package: mongodb-org
Version: 4.4.12

4. Viewing Installed Files

We can also inspect the files installed by MongoDB to determine the version.

  • Navigate to the MongoDB installation directory.
  • Look for a file named VERSION or similar.

Example:

$ cat /usr/local/mongodb/VERSION

Output:

4.4.12

Conclusion

Overall, Finding the exact version of installed MongoDB is crucial for various tasks, including compatibility testing, troubleshooting, and ensuring you’re using the latest features and security patches. By following the methods outlined in this article and experimenting with examples, you’ll be able to determine the MongoDB version installed on your system with ease.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads