top of page
Writer's pictureRajesh S Nair

Installing Mongo Database

Installing mongo database is comparatively simpler and hassle free as compared to traditional databases.The main idea of mongo database is to assist on the go application development with providing minimum overhead in understanding and implementing underlying database architecture.


Mongo Installation in Unix/Linux/Ubuntu


1. Import the public key used by the package management system.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5


Create a list file for MongoDB

echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list


2. Reload local package database

sudo apt-get update


3. Install the MongoDB packages

sudo apt-get install -y mongodb-org


Install a specific release of MongoDB

sudo apt-get install -y mongodb-org=3.6.4 mongodb-org-server=3.6.4 mongodb-org-shell=3.6.4 mongodb-org-mongos=3.6.4 mongodb-org-tools=3.6.4


4. Pin a specific version of MongoDB

echo "mongodb-org hold" | sudo dpkg --set-selections

echo "mongodb-org-server hold" | sudo dpkg --set-selections

echo "mongodb-org-shell hold" | sudo dpkg --set-selections

echo "mongodb-org-mongos hold" | sudo dpkg --set-selections

echo "mongodb-org-tools hold" | sudo dpkg --set-selections


Mongo Installation in Windows


To install MongoDB on Windows, download the Windows zip from the MongoDB

downloads page. Use the advice in the previous section to choose the correct version of

MongoDB. There are 32-bit and 64-bit releases for Windows, so select whichever version

you’re running. When you click the link, it will download the .zip. Use your favorite

extraction tool to unzip the archive.


Now you need to make a directory in which MongoDB can write database files. By

default, MongoDB tries to use the \data\db directory on the current drive as its data

directory (for example, if you’re running mongod on C:, it’ll use C:\data\db). You can

create this directory or any other empty directory anywhere on the filesystem. If you

chose to use a directory other than \data\db, you’ll need to specify the path when you

start MongoDB, which is covered in a moment.


Now that you have a data directory, open the command prompt (cmd.exe). Navigate to

the directory where you unzipped the MongoDB binaries and run the following:


If you chose a directory other than C:\data\db, you’ll have to specify it here, with the

--dbpath argument:

$ bin\mongod.exe --dbpath C:\Documents and Settings\Username\My Documents\db


Installing as a Service


MongoDB can also be installed as a service on Windows. To install, simply run with the

full path, escape any spaces, and use the --install option. For example:

$ C:\mongodb-windows-32bit-1.6.0\bin\mongod.exe

--dbpath "\"C:\Documents and Settings\Username\My Documents\db\"" --install


It can then be started and stopped from the Control Panel.


13 views0 comments

Recent Posts

See All

Comments


bottom of page