How to install mongoDB in Ubuntu 16.04??

MongoDB is a document-oriented database. Also, knows as NoSQL database because It does not use tables and rows like a relational database.

Following steps will tell you how to install MongoDB on ubuntu server.

Step 1: Run the following command to Import MongoDB public keys to your server

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

Step 2:  Run the following command to create MongoDB list file

echo "deb "$(lsb_release -sc)"/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

Step 3: Update your ubuntu server repository

sudo apt-get update

Step 4: Above 3 steps are recommended to install MongoDB, now comes to the main step:  install MongoDB from mongo-org

sudo apt-get install -y mongodb-org

Step 5:  This step is mandatory - Create a MongoDB system service file into the "/lib/systemd/system".

For going to this directory run following command
cd /lib/systemd/system
For creating MongoDB service file to run following command
sudo nano mongod.service

Paste below content into this file:

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

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

after paste, the code saves and exit from the file.

Step 6: After the creation of systemd  service of MongoDB, you need to update the systemd service by run the following command

systemctl daemon-reload

Step 7: Start and enable the services of MongoDB

for start run -  systemctl start mongod
For enable run - systemctl enable mongod

Other important points to remember:

  • Command for restart mongodb: sudo service mongod restart
  • After installation of mongodb, a mongodb folder is created and mongodb.conf file is created. In mongodb.conf file we can add all configuration of mongodb.
Path of mongodb folder: /var/lib
Path of mongodb.conf :  /etc
I hope it was helpful for you. Cheers!!!

One thought to “How to install mongoDB in Ubuntu 16.04??”

Leave a Reply

Your email address will not be published. Required fields are marked *