Quick Mongodb installation guide.

A practical guide to set up Mongodb locally for development purposes.

Posted by Allan Situma on January 29, 2020 · 1 min read
Currently, seven out of the ten highest valued global brands are data companies. Data as the new oil? Clearly. When you invest in data, its storage, its management and its analysis, you’re investing in innovation ― Thomas Harrer

Introduction to Mongodb

Mongodb arose in the mid-2000s under the NoSQL banner for use in big data processing and applications whose data would not fit well in a conventional database. It is termed as an open source database management system whose architecture is made up of collections and documents i.e. a document oriented database that supports multiple forms of data

Below is a quick recipe to install and get started with Mongodb

Prerequisites

  • Linux - Ubuntu 18.04 LTS
  • Good Internet
  • Basic CLI knowledge

Open your CLI and run the following codes line by line

 
#Install Mongo

sudo apt-get update
sudo apt-get install mongodb

#Set up auth
nano /etc/mongodb.con
edit auth=true

#Create admin user

// switch to the admin database
use admin

// create a new user to be stored in the admin database
db.createUser({
   user:"admin",
   pwd:"xxxxxxxxx",
   roles:[{ role: "userAdminAnyDatabase", db: "admin"  }] 
   })

// log out of mongo shell
exit

#log in as admin
mongo -u admin --authenticationDatabase admin -p

#create user etl

// ensure the new user is created under admin
use admin

// create new user and assign Read/Write permission only
db.createUser({ 
   user:"etl", 
   pwd:"etl",
   roles:[{ role: "readWrite", db: "etl"  }]
   })

#test if user was created
mongo -u etl --authenticationDatabase admin -p