Database Managment - Mongo DB

Back to Course

Lesson Description

Lession - #1397 MongoDB Environment

Install MongoDB On Windows

To introduce MongoDB on Windows, first download the most recent arrival of MongoDB from https://www.mongodb.com/download-focus

Enter the required details, select the Server tab, in it you can choose the version of MongoDB, operating system and, packaging as:

Presently introduce the downloaded document, naturally, it will be introduced in the organizer C:\Program Files\. MongoDB requires an information organizer to store its documents. The default area for the MongoDB information index is c:\data\db. So you want to make this organizer utilizing the Command Prompt. Execute the accompanying order arrangement.

C:\>md data
C:\md data\db

Then you want to determine set the dbpath to the made catalog in mongod.exe. For the equivalent, issue the accompanying orders.
In the order brief, explore to the receptacle registry current in the MongoDB establishment organizer. Assume my establishment envelope is C:\Program Files\MongoDB

C:\Users\XYZ>d:cd C:\Program Files\MongoDB\Server\4.2\bin
C:\Program Files\MongoDB\Server\4.2\bin>mongod.exe --dbpath "C:\data" 

This will show hanging tight for associations message on the control center result, which demonstrates that the mongod.exe cycle is running effectively. Presently to run the MongoDB, you really want to open another order brief and issue the accompanying order.

C:\Program Files\MongoDB\Server\4.2\bin>mongo.exe
MongoDB shell version v4.2.1
connecting to: mongodb://
Implicit session: session { "id" : UUID("4260beda-f662-4cbe-9bc7-5c1f2242663c">
} MongoDB server version: 4.2.1 >
This will show that MongoDB is introduced and run effectively. Next time when you run MongoDB, you really want to give just orders.

C:\Program Files\MongoDB\Server\4.2\bin>mongod.exe --dbpath "C:\data"
C:\Program Files\MongoDB\Server\4.2\bin>mongo.exe

Install MongoDB on Ubuntu

Run the accompanying order to import the MongoDB public GPG key −
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

Make a/and so on/adept/sources.list.d/mongodb.list document utilizing the accompanying order.

echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' 
   | sudo tee /etc/apt/sources.list.d/mongodb.list

Now issue the following command to update the repository −

sudo apt-get update

Next install the MongoDB by using the following command −

apt-get install mongodb-10gen = 4.2

In the above establishment, 2.2.3 is as of now delivered MongoDB form. Make a point to introduce the most recent form generally. Presently MongoDB is introduced effectively.

Start MongoDB

sudo service mongodb start

Stop MongoDB

sudo service mongodb stop

Restart MongoDB

sudo service mongodb restart

To use MongoDB run the following command.


This will connect you to running MongoDB instance.

MongoDB Help

To get a list of commands, type db.help(>
in MongoDB client. This will give you a list of commands as shown in the following screenshot.

MongoDB Statistics

To get details about MongoDB server, type the order db.stats(>
in MongoDB client. This will show the information base name,number of assortment and archives in the data set. Result of the order is displayed in the accompanying screen capture.

mongo db basics

mongo db basics