How to Install and Configure MongoDB on Ubuntu 14.04

This tutorial will show you how to install MongoDB NoSql database on ubuntu step by step.

What is MongoDB?

MongoDB is a free and open-source NoSql database used in modern web applications to increase database performance. This tutorial will help you to install and configure MongoDB on your ubuntu machine.

Now Lets’s start tutorial step by step..!!

Step-1: Open terminal by pressing Ctrl+Alt+T



Step-2: Ubuntu already include MongoDB repository but for getting most updated version of MongoDB we need to install it from MongoDB official website and also it is recommended way to installing it.
The Ubuntu package management tools (i.e. dpkg and apt) ensure package consistency and authenticity by requiring that distributors sign packages with GPG keys. Issue the following command to import the MongoDB public GPG Key:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

mongodb-1

Step-3: Create a list file for MongoDB. run below command.

echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

mongodb-2

Step-4: Update package repository by hitting below command

sudo apt-get update





Step-4: Now install latest version of MongoDB

sudo apt-get install -y mongodb-org

mongodb-3

Step-5: Now MongoDB installed successfully, Run below command to check.

mongo --help

mongodb-4

Below are the some basic command to start, stop MongoDb

sudo service mongod start
sudo service mongod stop
sudo service mongod restart

After that you can use MongoDB CLI command list to understand some basic commands.

mongo

Type help to display command list..

help

Use db.help() to display the database commands

db.help()

show dbs: to display all databases.

show dbs

Follow below link for more shell commands..
http://docs.mongodb.org/manual/reference/mongo-shell/

If you like this post please don’t forget to subscribe My Public Notebook for more useful stuff.