MongoDB is a popular, open-source NoSQL database that allows for flexible and scalable data storage. Here’s a brief overview:
Key Features:
- Document-based: Stores data in JSON-like documents, making it easy to work with complex data structures.
- NoSQL: Doesn’t use traditional table-based relational database management systems (RDBMS).
- Schema-less: No predefined schema, allowing for flexible data modeling.
- Scalable: Horizontally scalable, handling high traffic and large data volumes.
- High performance: Supports fast data retrieval and storage.
Basic Concepts:
- Collections: Groups of related documents, similar to tables in RDBMS.
- Documents: Individual data records, stored in JSON-like format.
- Fields: Key-value pairs within documents, similar to columns in RDBMS.
Installation
# Import the public key used by the package management system:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
# Create a list file for MongoDB:
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
# Reload the local package database:
sudo apt-get update
# Install the MongoDB packages:
sudo apt-get install -y mongodb-org
# Start MongoDB:
sudo systemctl start mongod
# Enable MongoDB to start on boot:
sudo systemctl enable mongod
# Check the status of MongoDB:
sudo systemctl status mongod
MongoDB should start on Port 27017.
Connect to MongoDB:
$ mongo