if you receive an error : Failed to start mongod.service: Unit mongod.service not found.
Run the following command first:
sudosystemctldaemon-reload
Verify that MongoDB has started successfully.
sudosystemctlstatusmongod
You can optionally ensure that MongoDB will start following a system reboot by issuing the following command:
sudosystemctlenablemongod
Stop MongoDB.
As needed, you can stop the mongod process by issuing the following command:
sudosystemctlstopmongod
Restart MongoDB.
You can restart the mongod process by issuing the following command:
MongoDB setup Docker
Begin using MongoDB.
Start a mongo shell on the same host machine as the mongod. You can run the mongo shell without any command-line options to connect to a mongod that is running on your localhost with default port 27017:
To show collections
Basic Commands
List all databases : show dbs
to switch to db : use <name_of_db>
to run a query : db.<name_of_collection>.[function name]
to iterate over many results : it
add : .pretty() to see json better
to find any one document from collection, just use .findOne()
to create new collection : db.createCollection("employees")