How to install MongoDB in Ubuntu

How to install MongoDB in Ubuntu
---------------------------------------------
This post will describe how to install and configure MongoDB. MongoDB is  an open source document database and of type no sql. It stores data in the form of JSON(JavaScript Object Notation)
as a combination of documents and collection. It is highly scable and performance


Software Version used in this post were as follows:
MongoDB v3.6 and Ubuntu 18.04
Step 1 Creating Source list file
Step 2 Installing MongoDB
Step 3 Start the Mongo Deamon
Step 4 Configure User for MongoDB
--------------------------------------------------------------
STEP 1 : CREATING SOURCE LIST FILE
Importing the public key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
Creating Souce list File
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

STEP 2 : INSTALLING MONGODB
Update the Repository
sudo apt-get update
Install MongoDB
sudo apt-get install -y mongodb-org

STEP 3 : START THE MONGOd
Start the mongo deamon using the following command
systemctl start mongod
To start mongoDB during Startup
systemctl enable mongod
To Use MongoDB use,
mongo

STEP 4 : CONFIGURE USER FOR MONGODB
In the MongoDB use the following command,
use admin
To create User
db.createUser({user:"username", pwd:"password", roles:[{role:"root", db:"admin"}]})
nano /lib/systemd/system/mongod.service
Add --auth in ExecStart
ExecStart=/usr/bin/mongod --auth --config /etc/mongod.conf
Reload the deamon for updating the user credentials
sudo systemctl daemon-reload
sudo service mongod restart
mongo -u username -p password

Comments

  1. This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points. To appreciate this I like to share some useful information

    Mongodb Training in Bangalore

    ReplyDelete

Post a Comment

Popular posts from this blog

How to install MRTG on UBUNTU

How to install Apache Tomcat in Ubuntu

How to mine cryptocurrency using unMineable