Installing MongoDB
Below is your requested beginner-friendly tutorial on installing MongoDB.
Preparing for Installation
Before you install MongoDB, make sure your system meets the requirements:
MongoDB requires a 64-bit CPU. It cannot run on a 32-bit CPU.
MongoDB requires at least 2GB of RAM.
MongoDB supports Linux, Windows, and macOS. Make sure your OS is up to date.
Ensure you have administrative privileges on your system.
Downloading MongoDB
Visit the MongoDB official download page at
https://www.mongodb.com/try/download/community
.Select the correct version for your operating system.
Choose the package type. For Windows, choose MSI. For macOS, choose TGZ. For Linux, there should be specific packages for various distributions.
Click
Download
.
Installing MongoDB
Windows
Open the downloaded MSI file to start the installation.
Follow the installation wizard’s prompts. Accept the license agreement.
Choose
Complete
installation type for a full installation, which includes MongoDB, MongoDB Compass (a GUI for MongoDB), and the MongoDB tools.Choose the
Run service as Network Service user
option.Choose
Install MongoDB Compass
if you want a graphical interface.Click
Install
.
macOS
Open the downloaded TGZ file. This will extract the files into a new directory.
Move the extracted files to your preferred location. A common location is
/usr/local/mongodb
.Add the MongoDB
bin
directory to your PATH. You can do this by editing your~/.bash_profile
file (or~/.zshrc
if you're using Zsh) and adding the following line:
export PATH=/usr/local/mongodb/bin:$PATH
- Save the file, then run
source ~/.bash_profile
(orsource ~/.zshrc
for Zsh) to reload your shell.
Linux
The installation process differs by distribution. Refer to the official MongoDB documentation for your specific distribution.
Starting MongoDB
Windows
MongoDB is installed as a Windows Service and will start up with your machine by default.
macOS and Linux
You can start MongoDB by running the mongod
command in your terminal. If you want MongoDB to start with your system, you have to configure it as a system service.
Verifying the Installation
In your terminal, run the command mongo
. This will open the MongoDB shell if your installation was successful.
Congratulations! You've now installed MongoDB on your system. In the next steps of your MongoDB journey, you'll learn how to create databases, insert data and query your data. Enjoy exploring MongoDB!