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 a 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.

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

Here, the default MongoD Service installs as 'Network Service user'. This is the Windows user account. We can also choose a local or domain user to run the service. This needs to specify the Account Domain, Account Name and Account Password.
It automatically takes --dbpath in Data Directory and --logpath in Log Directory.

Next, click finish to complete the installation.

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.

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 an administrator and go to the "c:\data\db".
Write the following command to start the server -
mongod

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 -
mongo

MongoDB Help
To know more about mongodb daemon, use the --help flag.
mongod --help
MongoDB Application Administration
Sometimes, there may be a need to know all current operations that the database is performing. To lists current running operations, use the db.currentOp() command.
>db.currentOp()
{
"inprog" : [
{
"desc" : "conn5",
"connectionId" : 5,
"client" : "127.0.0.1:55651",
"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.
db.killOp(opid)
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 an interface for users to visualize their schema and perform ad-hoc queries.
