MongoDB Installation

To install MongoDB, go to its official site and download under the community server suitable for your operating system and system type 32-bits or 64-bits. We can also get full installation guide for different operating systems on its official site.

Run mongodb installer

These are the screenshots that will help you while installing the downloaded exe or msi file. The default mongodb installation path is 'C:/Program Files/MongoDB/', but you can change this.

Install mongodb

Here, you can choose either Complete or Custom installation, it is recommended to choose Complete installation. In Custom installation, you may need to specify which executables are installed and where.

Install mongodb

Here, the default MongoD Service installs as 'Network Service user'. This is the Windows user account. We can also choose local or domain user to run the service. This need to specify the Account Domain, Account Name and Account Password.

It automatically takes --dbpath in Data Directory and --logpath in Log Directory.

Install mongodb

Next, click finish to complete the installation.

Install mongodb

Once this is installed, you can see the bin directory containing several binary files along with mongod.exe and mongo.exe. To run the mongodb from another path, add the mongodb path in the system environment variable path.

Set mongodb environment variable

Get started with Mongodb

To work on the MongoDB, we need to begin the server first. If you have set the installation path in an environment variable, you can start this from any directory.

Let's create a folder named data having a sub-folder named db where you want to run the server and open cmd as administrator and go to the "c:\data\db".

Write the following command to start the server -

Start Mongodb Server

MongoDB Port

By default, the MongoDB server starts on port 27017. We can also run the MongoDB on different port using --port flag.

mongod --port 27018

MonogoDB Database Directoy

The default directory where MongoDB stores data is under /data/db. We can specify different directory path.

mongod --dbpath /home/mongo/db --port 27018

Write the following command to start the client -

Start Mongodb Client

MongoDB Help

To know more about mongodb daemon, use the --help flag.

mongod --help

MongoDB Application Administration

Sometime, there is need to know all current operations that database is performing. To lists current running operations, use the db.currentOp() command.

	"inprog" : [
			"desc" : "conn5",
			"connectionId" : 5,
			"client" : "",
			"appName" : "MongoDB Shell",
			"clientMetadata" : {
				"application" : {
					"name" : "MongoDB Shell"
				"driver" : {
					"name" : "MongoDB Internal Client",
					"version" : "4.0.10"
				"os" : {
					"type" : "Windows",
					"name" : "Microsoft Windows 10",
					"architecture" : "x86_64",
			"active" : true,
			"currentOpTime" : "2019-08-01T15:32:35.630+0530",
			"opid" : 107720,
			"secs_running" : NumberLong(0),
			"microsecs_running" : NumberLong(42071),
			"op" : "command",
			"ns" : "admin.$cmd.aggregate",
			"command" : {
					"currentOp" : 1,
					"$db" : "admin"
			"numYields" : 0,
			"locks" : {

			"waitingForLock" : false,
			"lockStats" : {

	"ok" : 1

This command is basically used to check the show operations. We can stop any unwanted operation that is running and slowing down the process using killOp() command. Here is the syntax, "opid" is the operation's unique identifier.


Stop MongoDB Server

There is just one command to stop the MongoDB server. This command can run on the admin database only.

> use admin
switched to db admin
> db.shutdownServer()
server should be down...

Mongodb Community Compass

During mongodb installation, if you had checked to install the community compass, then it is installed with mongodb. This provides a graphical user interface. This contains interface for users to visualize their schema and perform ad-hoc queries.

Mongodb setup