View logs:
cat /var/log/mongodb/mongod.log
Configuration file location:
/etc/mongod.conf
Enter MongoDB shell:
mongo
List the databases;
mongo> show dbs
Create a new database or switch to a existing database:
mongo> use school
To view which database you are switched to:
mongo> db
Create collection inside the database:
mongo> db.createCollection("persons")
List collections:
mongo> show collections
To add the data to the collection:
mongo> db.persons.insert({
"name": "Jonh Doe",
"age": 45,
"location": "New York",
"salary": 5000
})
Retrieve data from the database:
mongo> db.persons.find()
Retrieve data from the database using a filter:
mongo> db.persons.find({"name": "John Doe"})