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
228
votes
29 answers

How can I run MongoDB as a Windows service?

How can I set up MongoDB so it can run as a Windows service?
heisthedon
  • 3,657
  • 3
  • 21
  • 24
226
votes
12 answers

How to listen for changes to a MongoDB collection?

I'm creating a sort of background job queue system with MongoDB as the data store. How can I "listen" for inserts to a MongoDB collection before spawning workers to process the job? Do I need to poll every few seconds to see if there are any changes…
Andrew
  • 227,796
  • 193
  • 515
  • 708
226
votes
46 answers

mongo - couldn't connect to server 127.0.0.1:27017

I am coming from riak and redis where I never had an issue with this services starting, or to interact. This is a pervasive problem with mongo and am rather clueless. Restarting does not help.I am new to mongo. mongo MongoDB shell version:…
Tampa
  • 75,446
  • 119
  • 278
  • 425
220
votes
4 answers

Possibility of duplicate Mongo ObjectId's being generated in two different collections?

Is it possible for the same exact Mongo ObjectId to be generated for a document in two different collections? I realize that it's definitely very unlikely, but is it possible? Without getting too specific, the reason I ask is that with an…
Anthony Jack
  • 5,333
  • 7
  • 28
  • 47
220
votes
6 answers

How to remove array element in mongodb?

Here is array structure contact: { phone: [ { number: "+1786543589455", place: "New Jersey", createdAt: "" } { number: "+1986543589455", place: "Houston", …
Justin John
  • 9,223
  • 14
  • 70
  • 129
218
votes
7 answers

How much faster is Redis than mongoDB?

It's widely mentioned that Redis is "Blazing Fast" and mongoDB is fast too. But, I'm having trouble finding actual numbers comparing the results of the two. Given similar configurations, features and operations (and maybe showing how the factor…
Homer6
  • 15,034
  • 11
  • 61
  • 81
218
votes
8 answers

Store images in a MongoDB database

How can I store images in a MongoDB database rather than just text? Can I create an array of images in a MongoDB database? Will it be possible to do the same for videos?
Chani
  • 5,055
  • 15
  • 57
  • 92
217
votes
11 answers

In Mongoose, how do I sort by date? (node.js)

let's say I run this query in Mongoose: Room.find({}, (err,docs) => { }).sort({date:-1}); This doesn't work!
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080
215
votes
10 answers

Changing MongoDB data store directory

Until now I have not been specifying a MongoDB data directory and have had only one 30 GB primary partition. I just ran out of space and added a new hard disk. How can I transfer my data (that is apparently in /var/lib/mongodb/) and configure…
Mark Gill
  • 3,721
  • 5
  • 22
  • 12
215
votes
7 answers

MongoDB: How to find the exact version of installed MongoDB

I have mongoDB 3.2 installed locally for Windows 7. I would like to find out its specific version (like is it 3.2.1, or 3.2.3 or...). How could I find it? If I open the database shell (mongo.exe), I can see it outputs: MongoDB shell version:…
Ville Miekk-oja
  • 18,749
  • 32
  • 70
  • 106
214
votes
10 answers

How to Import .bson file format on mongodb

I've exported the database on the server using mongodump command and dump is stored in .bson file. I need to import that in my local server using mongorestore command. However it's not working. What is the correct mongorestore command and what are…
binalay
  • 2,181
  • 2
  • 13
  • 4
213
votes
9 answers

How to sort mongodb with pymongo

I'm trying to use the sort feature when querying my mongoDB, but it is failing. The same query works in the MongoDB console but not here. Code is as follows: import pymongo from pymongo import Connection connection = Connection() db =…
WildBill
  • 9,143
  • 15
  • 63
  • 87
213
votes
4 answers

Why does the MongoDB Java driver use a random number generator in a conditional?

I saw the following code in this commit for MongoDB's Java Connection driver, and it appears at first to be a joke of some sort. What does the following code do? if (!((_ok) ? true : (Math.random() > 0.1))) { return res; } (EDIT: the code has…
Monstieur
  • 7,992
  • 10
  • 51
  • 77
213
votes
20 answers

Mongoimport of JSON file

I have a JSON file consisting of about 2000 records. Each record which will correspond to a document in the mongo database is formatted as…
amber4478
  • 6,433
  • 3
  • 20
  • 17
211
votes
5 answers

Best way to store date/time in mongodb

I've seen using strings, integer timestamps and mongo datetime objects.
xrado
  • 2,710
  • 3
  • 22
  • 20