Basics of MongoDB Shell

With MongoDB installed, (see Install Mongodb on Fedora 23)

get the server running with,

$ mongod

and remember this will hang, so open a new tab in your terminal to continue. In fedora this will be

Ctrl+shift+T

In that new terminal,

$ sudo mongo

Let us see what if any databases exist on the server,

 > show dbs

Say I have a database called ‘mydb’. Now if we want to use that databse we must use,

 > use mydb

To see what ‘collections’ or ‘tables’ exist in this database use,

 > show collections

If there is a collection called ‘movie’ and we’d like to look at it’s contents use,

 > db.movie.find()

To create a new database just start using it,

 > use newDB