Skip to content

Check MongoDB Version AQSA Spark By {Examples}

  • by

How to find or check the MongoDB version? MongoDB introduces new features, additions, and improvements with each new version to satisfy the changing demands of developers and enterprises. From their official website, we can download any version of MongoDB. However, keeping track of the MongoDB version is vital for maintaining compatibility, leveraging new features, and ensuring optimal performance.

This article will check various practices to check the MongoDB version on different platforms. In simple wrods you can check version

Open a command-line interface or terminal.

Run the mongo command to open the MongoDB shell.

Once in the MongoDB shell, run the db.version() command. This will display the version of the MongoDB server you are connected to.

Alternatively, simply run mongod –version

1. Check MongoDB Version using mongod –version command

To find or check the version of MongoDB installed within the system, we can try running the following command in the command line or terminal.

# Usage of mongod –version command
mongod –version

The command checks the version of MongoDB if it is installed and configured correctly on the machine, I am using the version number 6.0.5 of the MongoDB server, hence it is displayed on the following screen.

2. From Windows use “mongod.exe –version”

The next command,“mongod.exe –version also determines the version of the MongoDB server executable on a Windows operating system. The mongod.exe is the primary daemon process for MongoDB, responsible for handling database requests, managing data files, and providing access to the database. Run the command below to find the precise version of the MongoDB server running on the Windows system.

# Usage of mongod.exe -–version command
mongod.exe –version

The command here displays the version number of the MongoDB server executable, which is the same as for the previous command.

3. Use the “mongos –version” command

Alternatively, we have the mongos –version command that gets the version of the MongoDB sharding router (mongos) executable. Basically, the mongos is a component of MongoDB that acts as a query router, directing client requests to the appropriate shards in a sharded cluster. Running below command gives the specific version of the MongoDB.

# Usage of mongos –version command
mongos –version

Yields below output.

4. Using the “mongosh shell”

In addition, we can also examine the MongoDB server version while connecting the mongosh shell. All we have to do is just type mongosh in cmd and press Enter to start the mongosh shell. Then, it shows the Mongosh log ID, connection string, and the version of the MongoDB along with the mongosh shell.  The output displayed the version number of the connected MongoDB server.

If you want to install a mongosh shell on Windows, use the following link.

5. Using the db.version()

Moreover, the db.version() command is another option to retrieve the version of the MongoDB server that we are currently connected to within the mongosh shell. Once the mongosh shell connection is established, we can provide the following command.

# Usage of db.version() command command
db.version()

On the execution of the above command in the mongosh shell, it returned the version number of the connected MongoDB server.

You can also use this link to read more about this topic.

6. Using the “buildInfo command”

Conversely, we have another command  buildInfo of the mongosh shell for getting the mongosh version. This command generally retrieves detailed information about the MongoDB server’s build and version within the mongosh shell.

# Usage of buildInfo command
db.runCommand( { buildInfo: 1 } )

When we execute the prior command, it queries the buildInfo command on the admin database below. It returns a document containing various details about the MongoDB server, which also includes the MongoDB server version.

7. Using the “MongoDB compass” application

As we know that compass is a MongoDB client GUI application. If we use the MongoDB compass and want to know the MongoDB server version, we must follow these steps.

Firstly, connect to your MongoDB server by providing the necessary connection details in the connect dialog. Then, click on the Connect button for the desired database to open its details. Here, the MongoDB Compass Edition section represents the version of the MongoDB server we are connected to.

8. Conclusion

In conclusion, we are now familiar with ways to check the MongoDB version which is a straightforward process. The MongoDB version enables us to keep the database environment up-to-date and optimized.

 How to find or check the MongoDB version? MongoDB introduces new features, additions, and improvements with each new version to satisfy the changing demands of developers and enterprises. From their official website, we can download any version of MongoDB. However, keeping track of the MongoDB version is vital for maintaining compatibility, leveraging new features, and  Read More MongoDB 

Leave a Reply

Your email address will not be published. Required fields are marked *