Install MongoDB
To install MongoDB, downloading the latest and appropriate version of MongoDB that the system operating system and its version supports, is the first and foremost step.
- Download MongoDB from the link “http://www.mongodb.org/downloads“.
- MongoDB is available for every versions of Windows, except Window XP.
- MongoDB for Windows Server 2008 R2 edition runs only on Window Server 2008 R2, Windows 7 64 bit, and the newer version of windows
- MongoDb for 64 bit Windows runs only on newer version of Windows contains 64 bit operating system like, Window Server 2008 R2, Window 7 64 bit etc.
- MongoDb for 32 bit Windows runs on only 32 bit windows as it supports databases smaller than 2 GB and is thus generally used in testing and development purposes.
Steps to Install MongoDB in Windows:
Step 1: Get the downloaded MongoDB msi file at the folder you installed.
Step 2: Double click on the downloaded MongoDB msi file.
Step 3: Follow the step by step instructions to complete the installation process.
Step 4: The data directory to store all the information is \data\db by default. Create the data directory folder by command prompt md\data\db.
Step 5: To start MongoDB, run mongodb.exe using C:\Program Files\MongoDB\bin\mongodb.exe command in the command prompt.
Step 6: Create a specific directory for MongoDB log files, in order to create a configuration file and a directory path for MongoDB log output.
Steps to Install MongoDB in Linux:
Step 1: Download and extract the MongoDB binaries using step by step commands in the command prompt.
- mkdir mongodb
- cd mongodb
- curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.7.tgz
- tar xvf mongodb-linux-x86_64-3.4.7.tgz.
Step 2: Add MongoDB bin directory to PATH variable using step by step commands in the command prompt.
- mv mongodb-linux-x86_64-3.4.7 mongodb
- cd mongodb
- echo $PATH
- export PATH=$PATH:/home/journal/mongodb/mongodb/bin
Step 3: Create directory for MongoDB files and start it using step by step commands in the command prompt.
- mkdir data
- cd bin
- ./mongod –dbpath /home/journal/mongodb/mongodb/data &