where is mongo db database stored on local hard drive?

16,548

Solution 1

I believe on OSX the default location would be /data/db. But you can check your config file for the dbpath value to verify.

Solution 2

For posterity:

Run the mongo shell: mongo

In the shell run: db.adminCommand("getCmdLineOpts")

This will give the location of the relative files, including the db path. Here are the results from two machines I have running mongo.

"parsed": {
    "config": "/usr/local/etc/mongod.conf",
    "dbpath": "/usr/local/var/mongodb",
    "logappend": "true",
    "logpath": "/usr/local/var/log/mongodb/mongo.log"
    },


"parsed" : {
    "config" : "/etc/mongodb.conf",
    "dbpath" : "/var/lib/mongodb",
    "logappend" : "true",
    "logpath" : "/var/log/mongodb/mongodb.log",
},

Solution 3

Databases are, by default, stored in /data/db (some environments override this and use /var/lib/mongodb, however). You can see the total db size by looking at db.stats() (specifically fileSize) in the MongoDB shell.

Solution 4

> use database
switched to db database
> db.stats()
{
"db" : "database",
"collections" : 4,
"objects" : 32,
"avgObjSize" : 173.25,
"dataSize" : 5544,
"storageSize" : 24576,
"numExtents" : 4,
"indexes" : 3,
"indexSize" : 24528,
"fileSize" : 201326592,
"nsSizeMB" : 16,
"ok" : 1
}

dataSize - the size that your data consumes

fileSize - the mongo db file containing all of the collections

indexSize - is the size of any indexes you have created on that collection

nsSizeMB - a limit on how big your collection can be (this is not a mongo limitation, it is just there to stop developers bombarding collections in infinite loops)

Share:
16,548
The Internet
Author by

The Internet

yea

Updated on July 10, 2022

Comments

  • The Internet
    The Internet almost 2 years

    I'm scraping tweets and inserting them into a mongo database for analysis work in python. I want to check the size of my database so that I won't incur additional charges if I run this on amazon. How can I tell how big my current mongo database is on osx? And will a free tier cover me?