Steps for Setting up MongoDB on Ubuntu

Posted By : Kapil Bharadwaj | 26-Jun-2017

MongoDb is latest NOSQL database which is popularly used for storing large amounts of data with dynamic schemas in document-oriented storage .


This tutorial will guide you through the steps by following them,anyone can install and start working on popular Mongodb.
so in order to set up mongodb on your Ubuntu system you need to these 3 steps:
Step 1 — Importing the Public Key
Step 2 — Creating a List File/Creating source list file MongoDB
step 3— Update the repository
Step 4 — Installing and Verifying MongoDB

Assuming that you have the root access on your Ubuntu 14.04 LTS system,we are going through these steps.
#Step 1
so the First Step is Importing the public key.
in this step you have to import MongoDB GPG (GnuPG) keys to your server.
#Run the following command to import MongoDB GPG

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

if you have successfully imported the key you must see the output :

gpg: Total number processed: 1

gpg:    imported: 1  (RSA: 1) 

#Step 2
now,you have to add the MongoDB repository details so APT(Advanced Package Tool) will know where to download the packages from.
# To Create a source list file (file Path:etc/apt/sources.list.d/mongodb-org-3.0.list)

$ echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

#step 3
After adding the Repository details ,you have to update the package list
#Run the following command to update the package

$ sudo apt-get update

#step 4
After updating the package list you are ready to install MongoDB Package
# Run the command to install several packages of latest stable version of MongoDB

$ sudo apt-get install -y mongodb-org

if you followed all the four steps correctly,MongoDb is installed on your System by now.

After installation, MongoDB will be automatically running or you can also check the status of MongoDB by typing the following command.

$ service mongod status 

The output of the above command should be like:

mongod start/running, process 1612 

where your process id (1612 in my case) may be different.

You can also start,stop and restart MongoDB using the same above service command like:

$ service mongod start/stop/restart 

 

 

About Author

Author Image
Kapil Bharadwaj

Kapil is a Node Js Developer.

Request for Proposal

Name is required

Comment is required

Sending message..