Questions tagged [mongodb]

MongoDB is a scalable, high-performance, open source, document-oriented NoSQL database. It supports a large number of languages and application development platforms. Questions about server administration can be asked on https://dba.stackexchange.com.

MongoDB is a widely used, general-purpose, document-oriented database with a multitude of features including replication for redundancy and high availability and sharding for horizontal scaling.

The MongoDB Community Edition database server and tools are source-available under Server Side Public License (all versions released after October 16, 2018) or open-source under AGPL v3.0 license (versions released prior to October 16, 2018). Commercial Licenses are also available from MongoDB, Inc.

MongoDB offers a powerful query language, MQL, and provides the Aggregation Framework and Map/Reduce for even more complex queries. MongoDB uses the BSON format for storing data and the MongoDB Wire Protocol for communication between client drivers and the MongoDB server. Officially supported Drivers and Client Libraries are available for most popular programming languages, and there are also Community Supported Drivers which offer alternative implementations and support for further programming languages.

The latest MongoDB server releases can be installed via common packaging systems or downloaded as binary archives from mongodb.com.

The current production release series of MongoDB is 6.0. It is generally recommended to stay current with the latest minor release of a production release series (e.g. 6.0.1) to take advantage of bug fixes and backward-compatible improvements. For more information on the versioning scheme used by the server, see MongoDB Version Numbers.

MongoDB has a GUI called MongoDB Compass, which is a powerful GUI for querying, aggregating, and analyzing your MongoDB data in a visual environment. Compass is free to use and source available and can be run on macOS, Windows, and Linux.

FAQ

MongoDB Community Forums are the official home for community discussion, product/driver announcements, and introductions.

For help with data modeling (schema design), check out the Data Models documentation page, the Building with Patterns blog series, and M320: Data Modeling course at MongoDB University.

For information on MongoDB Security, view the Security section of the MongoDB Manual which includes a MongoDB Security Checklist.

MongoDB, Inc. (the company behind MongoDB) provides archives of many presentations from their events such as conferences and webinars. They also develop a number of related tools and services including MongoDB Cloud Manager, MongoDB Ops Manager, MongoDB Atlas, and MongoDB Compass.

Useful links

Related Tags

Initial Release:

Feb 11, 2009

Latest Production Release Series:

6.0 (July 19, 2022 - Release notes)

Books

Articles

174599 questions
171
votes
6 answers

How to define object in array in Mongoose schema correctly with 2d geo index

I'm currently having problems in creating a schema for the document below. The response from the server always returns the "trk" field values as [Object]. Somehow I have no idea how this should work, as I tried at least all approaches which made…
niels_h
  • 1,869
  • 2
  • 13
  • 15
170
votes
12 answers

Is mongodb running?

I have installed Mongodb and the PHP drivers on my Unix server. My question is how can I tell if Mongodb is running? Is there a simple command line query to check status? If I start it once from the shell will it keep running if I exit the shell…
user623520
170
votes
6 answers

MongoDB what are the default user and password?

I am using the same connection string on local and production. When the connection string is mongodb://localhost/mydb What is the username and password? Is it secure to keep it this way?
Juan Pablo Fernandez
  • 2,408
  • 3
  • 18
  • 32
169
votes
25 answers

unable to start mongodb local server

I am new to mongodb .. when i tried running mongodb local server with mongod command it failed to run and threw this error.. /usr/lib/mongodb/mongod --help for help and startup options Sat Jun 25 09:38:51 MongoDB starting : pid=1782 port=27017…
sakthig
  • 2,187
  • 3
  • 18
  • 22
169
votes
18 answers

MongoDB: exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating

I created /data/db in root directory and ran ./mongod: [initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating [initandlisten] shutdown: going to close listening…
whinytween96
  • 1,905
  • 3
  • 10
  • 9
169
votes
7 answers

MongoDB and "joins"

I'm sure MongoDB doesn't officially support "joins". What does this mean? Does this mean "We cannot connect two collections(tables) together."? I think if we put the value for _id in collection A to the other_id in collection B, can we simply…
TK.
  • 27,073
  • 20
  • 64
  • 72
169
votes
6 answers

How to Create and Use Enum in Mongoose

I am trying to create and use an enum type in Mongoose. I checked it out, but I'm not getting the proper result. I'm using enum in my program as follows: My schema is: var RequirementSchema = new mongooseSchema({ status: { type: String, …
Prabjot Singh
  • 4,491
  • 8
  • 31
  • 51
169
votes
2 answers

Mongo Shell - Console/Debug Log

Probably a dumb question. Experimenting with Mongo shell. I want to do something like: matt@linuxvm:~/mongodb-linux-i686-1.2.3/bin$ ./mongo MongoDB shell version: 1.2.3 url: test connecting to: test Thu Feb 25 20:57:47 connection accepted from…
user53791
168
votes
7 answers

Understanding MongoDB BSON Document size limit

From MongoDB The Definitive Guide: Documents larger than 4MB (when converted to BSON) cannot be saved to the database. This is a somewhat arbitrary limit (and may be raised in the future); it is mostly to prevent bad schema design and ensure …
0xdeadbeef
  • 4,090
  • 8
  • 33
  • 37
168
votes
9 answers

When should I use a NoSQL database instead of a relational database? Is it okay to use both on the same site?

What are the advantages of using NoSQL databases? I've read a lot about them lately, but I'm still unsure why I would want to implement one, and under what circumstances I would want to use one.
smfoote
  • 5,449
  • 5
  • 32
  • 38
166
votes
13 answers

db.collection is not a function when using MongoClient v3.0

I have been trying W3schools tutorial on nodeJS with MongoDB. When I try to implement this example in a nodeJS environment and invoke the function with an AJAX call, I got the error below: TypeError: db.collection is not a function at…
Elie Asmar
  • 2,995
  • 4
  • 17
  • 30
166
votes
45 answers

MongoError: connect ECONNREFUSED 127.0.0.1:27017

I'm using NodeJS wih MongoDB using mongodb package. When I run mongod command it works fine and gives "waiting for connection on port 27017". So, mongod seems to be working. But MongoClient does not work and gives error when I run node index.js…
Deepika P.
  • 1,699
  • 2
  • 10
  • 12
165
votes
10 answers

mongodb count num of distinct values per field/key

Is there a query for calculating how many distinct values a field contains in DB. f.e I have a field for country and there are 8 types of country values (spain, england, france, etc...) If someone adds more documents with a new country I would like…
Liatz
  • 4,997
  • 7
  • 28
  • 33
164
votes
4 answers

What does "Document-oriented" vs. Key-Value mean when talking about MongoDB vs Cassandra?

What does going with a document based NoSQL option buy you over a KV store, and vice-versa?
tesserakt
  • 3,231
  • 4
  • 27
  • 40
164
votes
5 answers

MongoDB Many-to-Many Association

How would you do a many-to-many association with MongoDB? For example; let's say you have a Users table and a Roles table. Users have many roles, and roles have many users. In SQL land you would create a UserRoles table. Users: Id …
Josh Close
  • 22,935
  • 13
  • 92
  • 140