3/27/15

How to Install MongoDB 3.0 on Ubuntu 14.10, 14.04, 12.04 and Debian


MongoDB (named from “huMONGOus“) is a full flexible index support and rich queries database. Its is a NoSQL database. MongoDB provides large media storage with GridFS. Click here for more details about this version of MongoDB.
This tutorial will help you to install MongoDB 3.0 Production Release on Ubuntu and Debian systems.
Adding Apt Repository
First import public key of 10gen repository in our system using following command.
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
Lets add MongoDB APT repository url in /etc/apt/sources.list.d/mongodb.list.
For Ubuntu:
$ echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list
For Debian:
$ echo "deb http://repo.mongodb.org/apt/debian "$(lsb_release -sc)"/mongodb-org/3.0 main" | sudo tee /etc/apt/sources.list.d/mongodb.list

Install MongoDB

After adding required APT repositories, use following commands to install MongoDB in your systems. It will also install all dependent packages required for mongodb.
$ sudo apt-get update
$ sudo apt-get install mongodb-org
If you want to install any specific version of MontoDB, define the version number like below
$ apt-get install mongodb-org=3.0.0 mongodb-org-server=3.0.0 mongodb-org-shell=3.0.0 mongodb-org-mongos=3.0.0 mongodb-org-tools=3.0.0

Start MongoDB Service

Start/Stop MongoDB using init script. Below are the example commands to do it.
$ sudo service mongod start
$ sudo service mongod stop

Verify MongoDB Installation

Use following command to check installed mongodb version
ubuntu@truetech4:~$ mongo --version

MongoDB shell version: 3.0.0
Connect MongoDB using command line and execute some test commands for checking proper working.
ubuntu@truetech4:~$ mongo

> use mydb;
> db.test.save( { truetech4: 100 } )
> db.test.find()

  { "_id" : ObjectId("52b0dc8285f8a8071cbb5daf"), "truetech4" : 100 }

  1 comment:

FIND US ON FACEBOOK

FIND US ON Twitter