SlideShare a Scribd company logo
IntroductionToMongodb
Agenda
What is No-SQL?
Why choose No-SQL?
MongoDB
Installation Guide
Configuration Guide
Common Database Commands
CRUD in MongoDB
Hello!
I am Vijay Shukla
You can find me at:
vijay@nexthoughts.com
1.
WhatisnoSql?
Not Only SQL Database.
A form of Data Base Managment System which is non-
relational.
Systems are often schema less, avoid joins and easy to scale.
Term NoSQL was coined in 1998, by Carlo Strozzi and again in
early 2009 with no:sql east confrence.
The better term would have been “No REL”, but NoSQL
caught on.
Redis, MongoDB, CouchDB, are type of NoSQL
Whychoosenosql
Amountofdatastoredisontheupandup
EasyDistribution
Key-Value(k-V)stores
Documentstores
Non-relational andschema-lessdatamodel
Lowlatencyandhighperformance
Highscalability
Reference:- https://www.devbridge.com/articles/benefits-of-nosql/
MongoDB
MongoDB is an open source document database that provides high
performance, high availability and automatic scaling.
A record in MongoDB is a document, which is a data structure
composed of fields and value pairs.
MongoDB objects are very similar to JSON Objects.
{
Name:”vijay”,
Age:23,
}
Installation Guide
1. Import public key used by package management system
a. sudo apt-key adv --keyserver
hkp://keyserver.ubuntu.com:80 --recv EA312927
1. Create a list file for MongoDB
a. echo "deb http://repo.mongodb.org/apt/ubuntu
precise/mongodb-org/3.2 multiverse" | sudo tee
/etc/apt/sources.list.d/mongodb-org-3.2.list
1. Reload local package database
a. sudo apt-get update
1. Install MongoDB packages
a. sudo apt-get install -y mongodb-org
1. Install a specific release
a. sudo apt-get install -y mongodb-org=3.2.4 mongodb-org-
server=3.2.4 mongodb-org-shell=3.2.4 mongodb-org-
mongos=3.2.4 mongodb-org-tools=3.2.4
Installation Guide
Starting MongoDB Service
Mongod
Once we have issue this command, MongoDB will start
up and you should see:
waiting for connections on port 27017
Connecting to Mongodb Service
mongo
However, after all the steps above and mongodb installed in our
machine, now if you try to start the mongodb service sudo service
mongod start it will fail.
"start: Unable to connect to Upstart: Failed to connect to socket
/com/ubuntu/upstart: Connection refused”
Failed to start mongod.service: Unit mongod.service failed to load:
No such file or directory.
You probably will be able to manually start it with sudo mongod -f
/etc/mongod.conf - but in this way MongoDB will remain connected as long as that
terminal is opened.
Configuration Guide
1. First we are going to change MongoDB’s default data store files from
/var/lib/mongodb to/data/db
1. So, first create a folder /data/db in your machine. Run sudo mkdir -p
/data/db
1. Now open the main mongo configuration file with sudo gedit
/etc/mongod.conf and change the “dbpath” line as below
1. Replace dbpath=/var/lib/mongodb TO dbpath=/data/db and then save
the file.
1. Then delete the old default /var/lib/mongodb
1. But the directory you created doesn’t have the correct permissions and
ownership right after creation – it needs to be writable by the user who
runs the MongoDB process. Hence we must make all the directories/files
owned by mongod user
1. Run sudo chown -R mongodb:mongodb /data/db
Configuration Guide
Document Structure
MongoDb Command
Basic Commands
show dbs List All Databases
use db_name Change DB or Create DB
db Show current selected database name
save Create both the database and collection
find Read
update Update
remove Delete
✖ Create
db.collection.insert(<document>)
db.collection.save(<document>)
db.collection.update( <query>, <update>, { upsert: true })
✖ Read
db.collection.find( <query>, <projection> )
db.collection.findOne( <query>, <projection> )
✖ Update
db.collection.update( <query>, <update>, <options> )
✖ Delete
db.collection.remove( <query>, <justOne> )
// save one user
$ db.users.save({ name: 'Chris' });
// save multiple users
$ db.users.save([{ name: 'Chris'}, { name: 'Holly' }]);
Create
Read
// show all users
$ db.users.find();
// find a specific user
$ db.users.find({ name: 'Holly' });
db.users.update({ name: 'Holly' }, { name: 'Holly Lloyd' });
Update
Delete
// remove all
db.users.remove({});
// remove one
db.users.remove({ name: 'Holly' });
Introduction to mongo db
Introduction to mongo db
Introduction to mongo db
ToBeContinue...
Theory of noSQL: CAP
What is Sharding?
ACID - BASE
How to store large file (>16 MB)
Grails Project with MONGODB
What Next
Thanks!
Any questions?

More Related Content

What's hot (20)

PPTX
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
SpringPeople
 
ODP
MongoDB
Martin Lazarov
 
PDF
Introduction to MongoDB
Mike Dirolf
 
PPTX
MongoDB
nikhil2807
 
PPTX
Basics of MongoDB
HabileLabs
 
PPT
Introduction to MongoDB
Ravi Teja
 
PPTX
Mongo db1
VandanaKukreja
 
PPTX
MongoDB 101
Abhijeet Vaikar
 
PPTX
The Basics of MongoDB
valuebound
 
PPTX
Mongo db
Akshay Mathur
 
PPTX
Mongo DB
Karan Kukreja
 
KEY
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Alex Nguyen
 
PPTX
Mongo DB 102
Abhijeet Vaikar
 
PPTX
Top 10 frameworks of node js
HabileLabs
 
PPTX
Mongo db intro.pptx
JWORKS powered by Ordina
 
PDF
Mongodb
Scott Motte
 
PPTX
MongoDB presentation
Hyphen Call
 
PDF
Mongo db dhruba
Dhrubaji Mandal ♛
 
PPT
MongoDB Pros and Cons
johnrjenson
 
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
SpringPeople
 
Introduction to MongoDB
Mike Dirolf
 
MongoDB
nikhil2807
 
Basics of MongoDB
HabileLabs
 
Introduction to MongoDB
Ravi Teja
 
Mongo db1
VandanaKukreja
 
MongoDB 101
Abhijeet Vaikar
 
The Basics of MongoDB
valuebound
 
Mongo db
Akshay Mathur
 
Mongo DB
Karan Kukreja
 
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Alex Nguyen
 
Mongo DB 102
Abhijeet Vaikar
 
Top 10 frameworks of node js
HabileLabs
 
Mongo db intro.pptx
JWORKS powered by Ordina
 
Mongodb
Scott Motte
 
MongoDB presentation
Hyphen Call
 
Mongo db dhruba
Dhrubaji Mandal ♛
 
MongoDB Pros and Cons
johnrjenson
 

Viewers also liked (20)

ODP
Groovy intro
NexThoughts Technologies
 
PPTX
Meta Programming in Groovy
NexThoughts Technologies
 
PDF
Unit test-using-spock in Grails
NexThoughts Technologies
 
PPTX
Java reflection
NexThoughts Technologies
 
PPTX
Actors model in gpars
NexThoughts Technologies
 
PPTX
MetaProgramming with Groovy
NexThoughts Technologies
 
PPT
Grails Controllers
NexThoughts Technologies
 
PPTX
Grails services
NexThoughts Technologies
 
PPTX
Grails with swagger
NexThoughts Technologies
 
PPTX
Groovy DSL
NexThoughts Technologies
 
PPTX
Grails domain classes
NexThoughts Technologies
 
ODP
Command objects
NexThoughts Technologies
 
PDF
Reactive java - Reactive Programming + RxJava
NexThoughts Technologies
 
PDF
Introduction to thymeleaf
NexThoughts Technologies
 
PPTX
Apache tika
NexThoughts Technologies
 
PDF
Introduction to mongo db
Chris Edwards
 
PDF
Introduction to mongo db by zain
KenAndTea
 
Meta Programming in Groovy
NexThoughts Technologies
 
Unit test-using-spock in Grails
NexThoughts Technologies
 
Java reflection
NexThoughts Technologies
 
Actors model in gpars
NexThoughts Technologies
 
MetaProgramming with Groovy
NexThoughts Technologies
 
Grails Controllers
NexThoughts Technologies
 
Grails services
NexThoughts Technologies
 
Grails with swagger
NexThoughts Technologies
 
Grails domain classes
NexThoughts Technologies
 
Command objects
NexThoughts Technologies
 
Reactive java - Reactive Programming + RxJava
NexThoughts Technologies
 
Introduction to thymeleaf
NexThoughts Technologies
 
Introduction to mongo db
Chris Edwards
 
Introduction to mongo db by zain
KenAndTea
 
Ad

Similar to Introduction to mongo db (20)

PDF
MongoDB
wiTTyMinds1
 
PPTX
Introduction to MongoDB.pptx
Surya937648
 
PDF
MongoDB - An Introduction
sethfloydjr
 
PDF
Mongodb By Vipin
Vipin Mundayad
 
PDF
How do i Meet MongoDB
Antonio Scalzo
 
PPTX
MongoDbPpt based on python installation.
jnvcomputerlab2024
 
PPTX
MongoDB.pptx
Sigit52
 
PPT
Mongo Bb - NoSQL tutorial
Mohan Rathour
 
DOCX
Mongo db report
Hyphen Call
 
PDF
SQL vs NoSQL, an experiment with MongoDB
Marco Segato
 
PDF
Philadelphia MongoDB User Group - Your First MongoDB Application
Michael Lynn
 
PPTX
MongoDB introduction features -presentation - 2.pptx
sampathkumar546444
 
PPTX
Mongo db
Gyanendra Yadav
 
PDF
MongoDB: Advantages of an Open Source NoSQL Database
FITC
 
PDF
10 mongo db
Ahmed Elbassel
 
PDF
MongoDB Lab Manual (1).pdf used in data science
bitragowthamkumar1
 
PPTX
Kalp Corporate MongoDB Tutorials
Kalp Corporate
 
KEY
Is MongoDB Right For Your Project (or Organization)
Tony Bibbs
 
PDF
Mongodb
Thiago Veiga
 
PPTX
Mongo db Quick Guide
Sourabh Sahu
 
MongoDB
wiTTyMinds1
 
Introduction to MongoDB.pptx
Surya937648
 
MongoDB - An Introduction
sethfloydjr
 
Mongodb By Vipin
Vipin Mundayad
 
How do i Meet MongoDB
Antonio Scalzo
 
MongoDbPpt based on python installation.
jnvcomputerlab2024
 
MongoDB.pptx
Sigit52
 
Mongo Bb - NoSQL tutorial
Mohan Rathour
 
Mongo db report
Hyphen Call
 
SQL vs NoSQL, an experiment with MongoDB
Marco Segato
 
Philadelphia MongoDB User Group - Your First MongoDB Application
Michael Lynn
 
MongoDB introduction features -presentation - 2.pptx
sampathkumar546444
 
Mongo db
Gyanendra Yadav
 
MongoDB: Advantages of an Open Source NoSQL Database
FITC
 
10 mongo db
Ahmed Elbassel
 
MongoDB Lab Manual (1).pdf used in data science
bitragowthamkumar1
 
Kalp Corporate MongoDB Tutorials
Kalp Corporate
 
Is MongoDB Right For Your Project (or Organization)
Tony Bibbs
 
Mongodb
Thiago Veiga
 
Mongo db Quick Guide
Sourabh Sahu
 
Ad

More from NexThoughts Technologies (20)

PDF
Alexa skill
NexThoughts Technologies
 
PDF
Docker & kubernetes
NexThoughts Technologies
 
PDF
Apache commons
NexThoughts Technologies
 
PDF
Microservice Architecture using Spring Boot with React & Redux
NexThoughts Technologies
 
PDF
Solid Principles
NexThoughts Technologies
 
PDF
Introduction to TypeScript
NexThoughts Technologies
 
PDF
Smart Contract samples
NexThoughts Technologies
 
PDF
My Doc of geth
NexThoughts Technologies
 
PDF
Geth important commands
NexThoughts Technologies
 
PDF
Ethereum genesis
NexThoughts Technologies
 
PPTX
Springboot Microservices
NexThoughts Technologies
 
PDF
An Introduction to Redux
NexThoughts Technologies
 
PPTX
Google authentication
NexThoughts Technologies
 
Docker & kubernetes
NexThoughts Technologies
 
Apache commons
NexThoughts Technologies
 
Microservice Architecture using Spring Boot with React & Redux
NexThoughts Technologies
 
Solid Principles
NexThoughts Technologies
 
Introduction to TypeScript
NexThoughts Technologies
 
Smart Contract samples
NexThoughts Technologies
 
My Doc of geth
NexThoughts Technologies
 
Geth important commands
NexThoughts Technologies
 
Ethereum genesis
NexThoughts Technologies
 
Springboot Microservices
NexThoughts Technologies
 
An Introduction to Redux
NexThoughts Technologies
 
Google authentication
NexThoughts Technologies
 

Recently uploaded (20)

PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
PPTX
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PDF
Continouous failure - Why do we make our lives hard?
Papp Krisztián
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PPTX
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPTX
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
Continouous failure - Why do we make our lives hard?
Papp Krisztián
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 

Introduction to mongo db

  • 2. Agenda What is No-SQL? Why choose No-SQL? MongoDB Installation Guide Configuration Guide Common Database Commands CRUD in MongoDB
  • 3. Hello! I am Vijay Shukla You can find me at: [email protected]
  • 5. Not Only SQL Database. A form of Data Base Managment System which is non- relational. Systems are often schema less, avoid joins and easy to scale. Term NoSQL was coined in 1998, by Carlo Strozzi and again in early 2009 with no:sql east confrence. The better term would have been “No REL”, but NoSQL caught on. Redis, MongoDB, CouchDB, are type of NoSQL
  • 9. MongoDB is an open source document database that provides high performance, high availability and automatic scaling. A record in MongoDB is a document, which is a data structure composed of fields and value pairs. MongoDB objects are very similar to JSON Objects. { Name:”vijay”, Age:23, }
  • 11. 1. Import public key used by package management system a. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 1. Create a list file for MongoDB a. echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list 1. Reload local package database a. sudo apt-get update 1. Install MongoDB packages a. sudo apt-get install -y mongodb-org 1. Install a specific release a. sudo apt-get install -y mongodb-org=3.2.4 mongodb-org- server=3.2.4 mongodb-org-shell=3.2.4 mongodb-org- mongos=3.2.4 mongodb-org-tools=3.2.4 Installation Guide
  • 12. Starting MongoDB Service Mongod Once we have issue this command, MongoDB will start up and you should see: waiting for connections on port 27017 Connecting to Mongodb Service mongo
  • 13. However, after all the steps above and mongodb installed in our machine, now if you try to start the mongodb service sudo service mongod start it will fail. "start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused” Failed to start mongod.service: Unit mongod.service failed to load: No such file or directory. You probably will be able to manually start it with sudo mongod -f /etc/mongod.conf - but in this way MongoDB will remain connected as long as that terminal is opened. Configuration Guide
  • 14. 1. First we are going to change MongoDB’s default data store files from /var/lib/mongodb to/data/db 1. So, first create a folder /data/db in your machine. Run sudo mkdir -p /data/db 1. Now open the main mongo configuration file with sudo gedit /etc/mongod.conf and change the “dbpath” line as below 1. Replace dbpath=/var/lib/mongodb TO dbpath=/data/db and then save the file. 1. Then delete the old default /var/lib/mongodb 1. But the directory you created doesn’t have the correct permissions and ownership right after creation – it needs to be writable by the user who runs the MongoDB process. Hence we must make all the directories/files owned by mongod user 1. Run sudo chown -R mongodb:mongodb /data/db Configuration Guide
  • 17. Basic Commands show dbs List All Databases use db_name Change DB or Create DB db Show current selected database name save Create both the database and collection find Read update Update remove Delete
  • 18. ✖ Create db.collection.insert(<document>) db.collection.save(<document>) db.collection.update( <query>, <update>, { upsert: true }) ✖ Read db.collection.find( <query>, <projection> ) db.collection.findOne( <query>, <projection> ) ✖ Update db.collection.update( <query>, <update>, <options> ) ✖ Delete db.collection.remove( <query>, <justOne> )
  • 19. // save one user $ db.users.save({ name: 'Chris' }); // save multiple users $ db.users.save([{ name: 'Chris'}, { name: 'Holly' }]); Create Read // show all users $ db.users.find(); // find a specific user $ db.users.find({ name: 'Holly' });
  • 20. db.users.update({ name: 'Holly' }, { name: 'Holly Lloyd' }); Update Delete // remove all db.users.remove({}); // remove one db.users.remove({ name: 'Holly' });
  • 25. Theory of noSQL: CAP What is Sharding? ACID - BASE How to store large file (>16 MB) Grails Project with MONGODB What Next

Editor's Notes

  • #8: Latency is a time interval between the stimulation and response.