Week-1: Install Mongo DB
Aim: To install MongoDB on Windows, download the installer from the
MongoDB website, run the installer, and follow the setup wizard.
Description:
MongoDB is a popularly used NoSQL database. It is widely used for web
application development and real-time storage. In this task MongoDB
Installation on Windows, you will walk through the step-by-step installation
and setup process of MongoDB.
A Step-by-Step Guide to MongoDB Installation on Windows Navigate to the
download site
Navigate to the official MongoDB website.
Install MongoDB 8.0 Community Edition on Windows using the default
installation wizard.
1. MongoDB Version
This task installs MongoDB 8.0 Community Edition. To install a different
version of MongoDB Community, use the version drop-down menu in the
upper-left corner of this page to select the documentation for that version.
2. Installation Method
To installs MongoDB on Windows using the default MSI installation wizard.
You can also install MongoDB on Windows by these other methods:
Install MongoDB using [Link].
Install MongoDB from the zip file
Procedure:
Mongo DB installation document for Windows
OS: Below installation is done on Windows 10:
1. Download msi file from below link:
[Link]
roduction
2. Run the msi file
Click Next
3. Accept the terms in the License Agreement and select Next
4. Select Complete
5. Select Install
6. Wait until you get the finish screen
7. Click Finish
8. Create folders in C drive: data>db
9. Add below path in the environment variable
10. Navigate to C:> ProgramFiles>MongoDB>Server>3.0>bin
11. Right click and run as administrator: Start the mongo db server
Once you start the server you will see a command prompt saying (1 connection
now open)
12. Start the mongo db database: Right Click on Mongo and run it as
administration
Once your database is started , it will be connected to the test
database by default Use command: show dbs it will show you all
dbs
MongoDB stores data in the form of Documents, which are JSON-like field –
value pairs. Mongo DB Documents are called BSON documents: (Binary
representation of JSON) with additional type information.
MongoDB stores all documents in collections. A collection is a group of related
documents that have a set of shared common indexes. Collections are
analogous to a table in relational databases.
Use dbname created database e.g. use nisha1
Good resource for learning Mongo DB:
[Link]
Some basic commands to try:
References:
[Link]
Result:
Week-2
Install MongDB Shell and Practice
Aim: To install MongoDB shell on Windows and practice shell commands
Description:
The MongoDB shell is a command-line interface that allows you to interact
with your MongoDB database. It enables you to run queries, manage your
database, and perform administrative tasks like backups and data migration.
To use the MongoDB shell on Windows, follow these steps:
1. Install MongoDB on your Windows system.
2. Open Command Prompt or PowerShell.
3. Navigate to the MongoDB installation directory or add it to your system’s
PATH.
4. Type mongo to start the MongoDB shell and connect to your local MongoDB
instance.
To check the MongoDB shell version, open the MongoDB shell and type the
following command:
[Link]()
Procedure:
Windows MongoDB Shell Installation
Mongosh works like the typical mongo predecessor, but it requires a
MongoDB shell of version 4.0 or higher. Over to the Windows MongoDB
Shell installation steps.
Step 1: Download the Mongosh Installer
To begin the Windows MongoDB Shell Install process, go to the download
page at [Link]
Choose your OS and your desired MongoDB version.
Click Download.
Step 2: Run the MongoDB Installer(a .msi file)
Go to your ‘Downloads’ folder.
Click on the installer.
Follow the instructions.
Step 3: Connect to A MongoDB Instance
This can be done in two distinct ways:
A) Locally
You can connect to a MongoDB instance locally by running
the ‘mongosh’ command. The ‘mongosh’ command will connect to the default
MongoDB port – 27017. This method is also equivalent to connecting with a
connection string.
> mongosh "mongodb://localhost:27017"
If you need to connect to a specific database, you will have to add the name of
the database to the path.
> mongosh "mongodb://localhost:27017/hevodb"
If the connection port can be changed, your MongoDB instance is not on the
default. Another way to connect to a mongodb instance is with the command-
line option —port.
> mongosh —-port 28089
B) Remote
This can also be done with a connection string and command-line options.
With the connection string:
o Example: mongosh “mongodb://[Link]”
o If the remote host in this case is MongoDB Atlas, copy the URL to
replace it.
With command-line options:
o Unlike the local connection, command-line options for remote
connection require the –host option.
o Example: mongosh –host [Link] –port 28015
Get a list of help options - MongoDB help commands One important
basics MongoDB command will help you work with the Mongo shell
easily: the help command. Run the help command to get a list of help
options available in the mongo shell.
Help
Result: