Let us now see the way to set up MongoDB on Windows.
Install MongoDB On Windows
To set up MongoDB on Windows, first down load the ultra-modern release of MongoDB from https://www.Mongodb.Com/down load-center.
Enter the specified information, pick the Server tab, in it you can select the version of MongoDB, working device and, packaging as:
Now deploy the downloaded record, by using default, it will likely be established inside the folder C:Program Files.
MongoDB requires a facts folder to keep its documents. The default region for the MongoDB information directory is c:datadb. So you need to create this folder the usage of the Command Prompt. Execute the subsequent command sequence.
C:\>md data
C:\md data\db
Then you need to specify set the dbpath to the created listing in mongod.Exe. For the identical, problem the following instructions.
In the command set off, navigate to the bin listing contemporary in the MongoDB set up folder. Suppose my set up folder is C:Program FilesMongoDB
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 display anticipating connections message at the console output, which indicates that the mongod.Exe procedure is strolling efficaciously.
Now to run the MongoDB, you want to open another command set off and issue the following command.
C:\Program Files\MongoDB\Server\4.2\bin>mongo.exe
MongoDB shell version v4.2.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("4260beda-f662-4cbe-9bc7-5c1f2242663c") }
MongoDB server version: 4.2.1
>
This will display that MongoDB is installed and run efficiently. Next time while you run MongoDB, you want to problem only instructions.
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 following command to import the MongoDB public GPG key −
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
Create a /and many others/apt/sources.Listing.D/mongodb.List report the use of the following
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen'
| sudo tee /etc/apt/sources.list.d/mongodb.list
Now trouble the subsequent command to replace the repository −
sudo apt-get update
Next install the MongoDB by using the subsequent command −
apt-get install mongodb-10gen = 4.2
In the above installation, 2.2.3 is currently released MongoDB model. Make sure to put in the present day model constantly. Now MongoDB is set up effectively.
Start MongoDB
sudo service mongodb start
Stop MongoDB
sudo service mongodb stop
Restart MongoDB
sudo service mongodb restart
To use MongoDB run the subsequent command.
mongo
This will connect you to strolling MongoDB instance.
MongoDB Help
To get a list of instructions, kind db.Assist() in MongoDB client. This will give you a list of commands as shown in the following screenshot.
MongoDB Statistics
To get stats approximately MongoDB server, type the command db.Stats() in MongoDB patron. This will show the database call, range of collection and documents in the database. Output of the command is shown inside the following screenshot.