MongoDB
Last updated
Was this helpful?
Last updated
Was this helpful?
To connect to database
use the connect settings in mongodb atlas
Starting local database server
After installing, you can start the mongod by
if you receive an error : Failed to start mongod.service: Unit mongod.service not found.
Run the following command first:
Verify that MongoDB has started successfully.
You can optionally ensure that MongoDB will start following a system reboot by issuing the following command:
Stop MongoDB.
As needed, you can stop the process by issuing the following command:
Restart MongoDB.
Begin using MongoDB.
To show collections
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")
To shutdown db server
You can restart the process by issuing the following command:
Start a shell on the same host machine as the . You can run the shell without any command-line options to connect to a that is running on your localhost with default port 27017: