Databases 6 min read

Introduction to MongoDB: Features, Installation, and Basic Usage

This article introduces MongoDB, an open-source document-oriented database, outlines its key features such as indexing, sharding, and MapReduce, and provides step-by-step instructions for installing and running MongoDB on a system using Homebrew, along with basic shell commands.

Test Development Learning Exchange
Test Development Learning Exchange
Test Development Learning Exchange
Introduction to MongoDB: Features, Installation, and Basic Usage

What is MongoDB?

MongoDB is an open-source database system written in C++, based on distributed file storage.

Under high load, adding more nodes can maintain server performance.

MongoDB aims to provide scalable high-performance data storage for web applications.

MongoDB stores data as documents composed of key‑value pairs; documents resemble JSON objects and can contain nested documents, arrays, and arrays of documents.

Main Features

MongoDB is a document‑oriented database that is simple and easy to use.

You can create indexes on any field (e.g., FirstName="Sameer", Address="8 Gandhi Road") to achieve faster sorting.

It supports local or networked data mirroring, giving strong scalability.

When load increases, data can be sharded across additional nodes in the network.

MongoDB offers rich query expressions using JSON‑style syntax, allowing easy querying of embedded objects and arrays.

The update() command can replace whole documents or specific fields.

Map/Reduce is used for batch processing and aggregation.

Map functions emit(key,value) for each record, passing key and value to Reduce functions.

Map and Reduce functions are written in JavaScript and can be executed via db.runCommand or the mapreduce command.

GridFS is a built‑in feature for storing large numbers of small files.

MongoDB allows server‑side scripting with JavaScript functions.

MongoDB supports many programming languages: Ruby, Python, Java, C++, PHP, C#, etc.

Installation is straightforward.

Setting up MongoDB (personal recommendation: use Homebrew; the tutorial below uses brew; feel free to comment for other operating systems).

1. Install MongoDB

sudo brew install mongodb

2. Install MongoDB with TLS/SSL support

sudo brew install mongodb --with-openssl

3. Install the latest development version

sudo brew install mongodb --devel

Running MongoDB

1. Create a data directory for the database: /data/db

sudo mkdir -p /data/db

2. Start MongoDB (default data directory is /data/db )

sudo mongod
# If the global PATH is not set, navigate to the binary directory
cd /usr/local/mongodb/bin
sudo ./mongod

Open another terminal and run:

$ cd /usr/local/mongodb/bin
$ ./mongo
MongoDB shell version v3.4.6
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.6

Welcome to the MongoDB shell.

Using the MongoDB shell

1. Show databases: show dbs

2. Switch to a database: use

3. Show collections: show tables

4. Query all documents in a collection: db.tablename.find()

Feel free to try setting up MongoDB yourself; the steps are simple and knowledge builds gradually.

Long‑press the QR code below to follow for more automation learning resources.

databasetutorialInstallationmongodbNoSQLdocument store
Test Development Learning Exchange
Written by

Test Development Learning Exchange

Test Development Learning Exchange

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.