Find us on facebook

Showing posts with label MongoDB. Show all posts
Showing posts with label MongoDB. Show all posts

Feb 18, 2018

Install and configure mongo db on Ubuntu

1) Find ubuntu version
lsb_release -a

2) Import the public key used by the package management system
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

3) Create a list file for MongoDB (16.04 LTS ubuntu)
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

4) sudo apt-get update

5) Install latest mongodb packages
sudo apt-get install -y mongodb-org

Refference : https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

Set user and give read write access to db

use admin

db.createUser({
    user: 'test',
    pwd: 'testpassword',
    roles: [{ role: 'readWrite', db:'admin'}]
})


6) Edit your MongoDB config file. On Ubuntu:
sudo vim /etc/mongod.conf

7) open MongoDB to all IPs
#  bindIp: 127.0.0.1  <- comment out this line

8) Find #security: section and add following
security:
  authorization: 'enabled'