Contents
What are MongoDB commands?
Basic commands for mongoDB
- show dbs.
- use DATABASE_NAME.
- db.
- db.dropDatabase()
- db.createCollection(name)
- Show collections.
- db.COLLECTION_NAME.drop()
- >db.COLLECTION_NAME.find()
Which package is needed for MongoDB?
MongoDB Community Edition Packages
Package Name | Description |
---|---|
mongodb-database-tools | Contains the following MongoDB database tools: mongodump mongorestore bsondump mongoimport mongoexport mongostat mongotop mongofiles |
mongodb-org-database-tools-extra | Contains the install_compass script |
What do you need to know about MongoDB?
When you start mongod you’re basically saying “start the MongoDB process and run it in the background”. mongod has several default parameters, such as storing data in /data/db and running on port 27017. mongo is the command-line shell that connects to a specific instance of mongod.
How to start multiple instances of MongoDB?
You just need to create another folder (ex: mongodb2) dbpath for the second instance, and run it in different port (ex: 27018) Here is how I start 4 mongod’s on the same pc to emulate production environment in development environment. To start mongod you should use separate config for each mongod. Take 4 configs and start mongods using them:
What’s the difference between mongo and mongod shell?
mongod has several default parameters, such as storing data in /data/db and running on port 27017. mongo is the command-line shell that connects to a specific instance of mongod. When you run mongo with no parameters it defaults to connecting to the localhost on port 27017.
Do you USE command line parameters to start Mongo?
Ideally, when doing anything other than just “playing around”, you’ll use the Command Line Parameters for starting mongod. By the same measure you should start the mongo shell with explicit instructions. Based on your description, I think you may be encountering an issue regarding the use of default databases.