Installation and Basic Configuration
Last updated
Last updated
MongoDB is a popular NoSQL database known for its high performance, scalability, and flexibility. This guide will walk you through the process of installing and configuring MongoDB on your system. Whether you are using Windows, macOS, or Linux, this step-by-step tutorial will help you get started with MongoDB.
Before we begin, ensure you have the following:
Administrator access to your system
Basic knowledge of command-line interface
Step 1: Download MongoDB
Go to the and select the MongoDB Community Server.
Choose the version compatible with your Windows OS and download the installer.
Step 2: Install MongoDB
Run the downloaded .msi
file.
Follow the setup wizard, selecting the Complete setup type.
Choose to install MongoDB as a service.
Configure the Data and Log directories (default paths are usually sufficient).
Step 3: Verify Installation
Open Command Prompt.
Run the command:
This should display the installed MongoDB version.
Step 1: Install Homebrew
If you haven't installed Homebrew, run:
Step 2: Install MongoDB
Tap the MongoDB formula:
Install MongoDB:
Step 3: Start MongoDB
Start MongoDB as a service:
Verify installation by checking the version:
Step 1: Import the Public Key
Step 2: Create a List File for MongoDB
Step 3: Reload the Local Package Database
Step 4: Install MongoDB Packages
Step 5: Start MongoDB
Step 6: Verify Installation
MongoDB’s configuration file is located at /etc/mongod.conf
by default. Key sections include:
Storage: Configures the storage engine and database file paths.
Net: Configures network settings including the port MongoDB listens on.
Security: Configures security options like authorization.
/etc/mongod.conf
)Windows
Use the net
command:
macOS
Using Homebrew services:
Linux
Using systemctl
:
Create an administrative user.
Restart MongoDB with authentication enabled.
Authenticate using the created user:
You have now installed and configured MongoDB on your system. This guide covered the essential steps to get you started with MongoDB, including installation, basic configuration, and enabling authentication. For more detailed configuration and advanced features, refer to the .