Thursday, 1 September 2016

How to install mongodb in ubuntu 16.04

MongoDB is a NoSQL database . NoSQL means "Not only sql" it covers any database that is not a traditional relational database management system.NoSQL databases are more specialized for types of data, which makes them more efficient and better performing than any other RDBMS database. MongoDB is a cross-platform and open source document based database, a kind of NoSQL database.It is designed with both scalability and developer agility in mind. Instead of storing your data in tables and rows it store JSON like documents with dynamic schemas.

install mongodb in ubuntu

Step 1 : Importing the Public Key:

A GPG keys of the software distributor are required by the Ubuntu package manager apt to ensure package consistency. This command will import the mongoDB keys to your server.

sudo apt-key adv --keyserver hkp:// --recv EA312927

Output of above command is look like:

After successfully importing the key, you will see:
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

Step 2 : Create source list file MongoDB:

sudo echo "deb xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

Step 3 : Now, we need to update the package list using the following command.

sudo apt-get update

Step 4 : Now install and verifiy MongoDB.

sudo apt-get install -y mongodb-org

It will install several latest packages of stable version of MongoDB along with helpful management tools for the MongoDB server.

Step 5 : Additionaly we need to create a unit file. A unit file tells systemd i.e how to manage the resource.

sudo nano /etc/systemd/system/mongodb.service

Paste the following contents into mongodb.service file:

Description=High-performance, schema-free document-oriented database

ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf


Step 6 : Start the newly created service like:

sudo systemctl start mongodb

Start mongodb and add it as service to be started at boot time:

sudo systemctl start mongod
sudo systemctl enable mongod

You can also check the status of the service like.

sudo systemctl status mongodb

Open Mongodb in your shell:

sudo mongo

for mongodb database operation like insert ,delete , update etc you can create it on command. But if you look for a gui tool i would suggest rockmongo is a pretty nice gui based tool for mongodb.

Featured post

How to create dynamic schema in mongodb

Sometime what we need in our application is to create mongodb schema for collection and some of our collection schema are same but names are...

Popular Posts