Check the Version of Mongodb
How to Check the Version of Mongodb
The simplest approach to check the mongodb version is to run the “–help” option with the keyword “mongod”. We have opened the command line prompt in our system and placed the following command on the terminal screen of our system. The usage of this command helps us to get the flag that checks and outputs the current version of the mongodb application.
The command of “mongod –help” listed all the general options as the output which might be used for running the mongodb in our operating system. Due to the lengthy list of options, we have just shown the option “–version”. The “–version” is the option which we use along with the mongodb shell to get the mongodb version.
–networkMessageCompressors arg (=snappy,zstd,zlib)
Comma-separated list of compressors to
use for network messages
-h [ –help ] Show this usage information
–version Show version information
Method # 1: Check the Mongodb Version with the Mongod Command
Now, we can use the –version flag to get the currently installed version of the mongodb. Here, we do not have a mongodb connection as the path is not given or the mongodb shell is not opened. When we are not connected to the mongodb then we can run the command below in the command prompt of our system. The “–version” flag is used with the “mongod” command.
Once the “mongod –version” command is executed, the version of the mongodb is displayed as follows. It includes the current mongodb version and further build information on the mongodb application.
Method # 2: Check the Mongodb Version with the Mongo Command
Another approach to check the mongodb version is using the mongo method. In the command prompt, we have to use the keyword “mongo” which is the shell for running the mongodb queries. The mongo is employed with the option “–version” to check the mongodb shell version. The general representation of the mongo command to fetch the version is pasted below.
The version of the mongo shell in our operating system is as follows:
Method # 3: Check the Mongodb Version with the File Path
The methods above are a way to obtain the mongodb version when the connection with the mongodb is not established. Here, we will fetch the version of our mongodb application by accomplishing the path of the file where the mongodb shell is located. To do this, we have launched the command prompt and with the “cd” command the full path of the mongodb shell is specified on the terminal. Then, press enter to execute the command.
The file path of mongodb is given and the system successfully finds the specified path of the mongodb. After that, we have given the name of the application “mongod.exe” which also utilizes the “–version” option for getting the mongodb version.
From the access of the file path of the mongodb, we have fetched the current mongodb version in the output represented below.
Method # 4: Check the Mongodb Version with the db.version() Command
All the aforementioned commands use the command prompt for getting the mongodb version. We also have another method for figuring out the mongodb version: by launching the mongodb shell. In this instance, we first made the connection. Then, run the following query in the mongodb shell. The “db” keyword is used with the “version()” method for generating the version of the mongodb used in the system.
Method # 5: Check the Mongodb Version with the BuildInfo Parameter Command
The last command line interface approach to get the mongodb version is using the “builInfo” method. A buildInfo command is a management tool that provides a build report for the current Mongod. We have employed the “runCommand()” query which takes the “buildInfo” command as a parameter. The buildInfo command is further set with the value “1” known as the true boolean value.
The output of the buildInfo command generates the version and the summary of the mongodb server.
Method # 6: Check the Mongodb Version with the GUI Interface
The graphical user interface is the most appealing approach to checking the version of the mongodb. If the command line interface or any specific mongodb shell is not easy to use, then we can use the mongodb compass. The mongodb compass application is a GUI approach to getting the mongodb version. Firstly, we have launched the mongodb compass and built a connection with our existing local host. After that, we have three aligned dots on the left sidebar which on click displayed a few options. Among all the listed options, mouse over to the option “Connection info”. The screenshot of the mongodb compass is shown below which will be easy to follow the step for checking the mongodb version.
The “Connection info” generates the pop-up page where the information about the mongodb connection is given. On the pop-up page, we have a field “Edition”. Below the “Edition” field, the edition information of the mongodb is displayed as “MongoDB 6.0.3 Community”
The article is to check the version of mongodb. We have explored all the possible ways to get the mongodb version. A few methods are used to get the mongodb server version and other methods are for fetching the mongodb shell version. We first used the command line interface to check the mongodb version. Afterward, we have a mongodb compass GUI application were checking the mongodb version is easiest.