MongoDB is a cross-platform document-oriented and NoSQL database. MongoDB Community Edition installation is a straightforward process for beginner.
In this guide, we’ll walks you through the steps to install and setup MongoDB Community Edition on Microsoft Windows operating system.
What We Used
- Microsoft Windows 7
- MongoDB 3.2.9 binary file
1. Download MongoDB
Download the MongoDB latest stable release .msi
binary file (This guide use version 3.2.9) from MongoDB download page for 32-bit or 64-bit Windows platform.
Note: For 64-bit Windows users, it is recommended to install 64-bit version MongoDB because 32-bit version is limited to approximately 2GB total dataset size per server but 64-bit version has no this restriction.
2. Install MongoDB
After download the MongoDB, double click the .msi
file to start the installation process.
Click Next button to start the setup.
Check to accept the license agreement and click Next button.
Click Complete button to install all the program features.
Click Install button to start the installation.
After finish the installation, click Finish button to complete the installation.
This is the MongoDB installation directory.
3. Add MongoDB to PATH
Open the Environment Variables dialog box, under System Variables, add MongoDB bin directory C:\Program Files\MongoDB\Server\3.2\bin
to the Path variable.
Note: Remember to put a semicolon character ;
as delimiter to separate the MongoDB bin path with other paths.
4. Create Data Directory
Before start the MongoDB, it is required to create a data directory for MongoDB to store the database data. By default, MongoDB will store the data in the C:\data\db
.
Note: MongoDB does not create the data directory automatically, you need to create the data directory manually.
5. Start MongoDB
Execute the following command in Command Prompt window:
mongod
If you see the following line in Command Prompt window, you have successfully started the MongoDB server:
[initandlisten] waiting for connections on port 27017
By default, MongoDB server will be listening to port 27017
for new connections.
6. Connect to MongoDB
After started the MongoDB, you can connect to MongoDB via MongoDB shell. Open another Command Prompt window and execute the following command:
mongo
Now you are in the MongoDB shell and successfully connected to test
database in MongoDB server.
C:\Users\chankok>mongo
MongoDB shell version: 3.2.9
connecting to: test
> _
Understand the Version Number
MongoDB version number contain three parts. The second part of the version number will tell you whether it is a stable version or development version.
- Even number – It is stable or production version. For example, version
3.2.9
. - Odd number – It is unstable or development version. For example, version
3.3.15
.
Summary
Welcome to MongoDB world! You have successfully installed MongoDB Community Edition on Windows.