Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default database path for MongoDB?

Tags:

mongodb

I got an error about dbpath (/data/db/) does not exist, but /etc/mongodb.conf named it dbpath = /var/lib/mongodb. So, which is the default dbpath for MongoDB?

like image 587
holys Avatar asked Oct 05 '12 01:10

holys


People also ask

Where does MongoDB store default data?

By default MongoDB data files are stored in C:\ProgramData\FotoWare\FotoWeb\Operations\MongoDBData.

What is the default database in MongoDB client?

In MongoDB default database is test. If you did not create any Database and started inserting collection then all collections are stored in the Default Database. Show list of Databases : You can check currently selected database, using the command “show dbs“.

How do I set a path in MongoDB?

Click on environment variables button under the advanced tab in system properties dialog. Select path variable and click on the edit button. Add new path variable, copy and paste the bin path location of the MongoD files installed. In my system, MongoDB is installed in “C:\Program Files\MongoDB\”.


2 Answers

The default dbpath for mongodb is /data/db.

There is no default config file, so you will either need to specify this when starting mongod with:

 mongod --config /etc/mongodb.conf 

.. or use a packaged install of MongoDB (such as for Redhat or Debian/Ubuntu) which will include a config file path in the service definition.

Note: to check the dbpath and command-line options for a running mongod, connect via the mongo shell and run:

db.serverCmdLineOpts() 

In particular, if a custom dbpath is set it will be the value of:

db.serverCmdLineOpts().parsed.dbpath           // MongoDB 2.4 and older db.serverCmdLineOpts().parsed.storage.dbPath   // MongoDB 2.6+ 
like image 58
Stennie Avatar answered Sep 20 '22 18:09

Stennie


I have version 2.0.7 installed on Ubuntu and it defaulted to /var/lib/mongodb/ and that is also what was placed into my /etc/mongodb.conf file.

like image 26
HeatfanJohn Avatar answered Sep 21 '22 18:09

HeatfanJohn