MongoDB Installation
How to download and install the MongoDB Community Server.
MongoDB can be downloaded and installed for free from the MongoDB website. It is available in Community Server and Enterprise Server editions. The difference between the two is that the Enterprise Server includes extra functionality, such as in-memory storage engine, encrypted storage engine, advanced security, and a commercial licence.
This tutorial uses the MongoDB Community Server.
Supported Platforms
MongoDB Community Server can be installed on Windows, Mac, Solaris, and various Linux distributions. It is available for download from the MongoDB website. There are links to installation instructions (I've included these links below).
The MongoDB website will auto-detect your operating system and display the tab with the applicable download options for that system. If you're downloading MongoDB for use on a different operating system, change to the applicable tab.
Installation Instructions
The MongoDB website include installation instructions for Windows, Mac, and Linux. Here they are:
Here's a quick outline of what's included:
Windows installation includes an installation wizard to guide you through the installation. There's also an option for an unattended installation.
Mac and Linux installation is quite straight forward and consists of the following steps:
- Download the binary files.
- Extract the files.
- Copy the extracted archive to the target directory.
- Ensure the location of the binaries is in the PATH variable.
There's also a Homebrew option for Mac which makes installation even easier.
Create the Data Directory
This information is included in the above installation links.
MongoDB stores its data in a data directory. You need to create this data directory.
To create it in the default location, create a directory at /data/db (or \data\db on Windows).
By default, the mongod process (the primary daemon process for the MongoDB system) will look for the data directory at these locations, however, MongoDB gives you the option of using a different location. If you do specify a different location, you will need to pass that location in as a parameter when you startup MongoDB.
Check Permissions
Once you've created the data directory, check that the user account running mongod has read and write permissions for it.
Start MongoDB
To start MongoDB, use mongod
(Linux/Mac) or mongod.exe
(Windows).
This assumes that the path has been added to your PATH. If it hasn't, you'll need to provide the full path to the mongod binary.
Once the mongod process has started, you should see a waiting for connections message in the console output which indicates that the mongod process is running successfully.
Leave this Terminal/Command window open in the background. If you need to use Terminal/Command Prompt for anything else (such as running the MongoDB Shell), open a new window.