Where is mongo database folder on the filesystem
I'm using Ubuntu 16.04. I have set up a database MongoDB
. When I start it (with mongod
command) it says that database is located at /data/db
(dbpath=/data/db
).
The database works fine. But in files explorer I cannot find that folder. I've looked in Computer
folder and in Home
(Computer/home/<my name>
) folder.
I also showed hidden files and folders with Ctrl+H.
How can I find my database folder?
Solution 1:
You should be able to find the location in the configuration file: /etc/mongod.conf
grep -i dbPath /etc/mongod.conf
According to mongodb docs:
The default path is /data/db
directory
By default, MongoDB listens for connections from clients on port 27017, and stores data in the /data/db directory.
If dbPath
is set, the mongodb will use the directory specify by dbPath
If you want
mongod
to store data files at a path other than/data/db
you can specify adbPath
. ThedbPath
must exist before you startmongod
. If it does not exist, create the directory and the permissions so thatmongod
can read and write data to this path. For more information on permissions, see the security operations documentation.
Solution 2:
When using linux (Ubuntu), when you install mongodb, it is automatically configured and run by default. The default dbpath is located in mongodb.conf
. You should see the following lines:
# Where to store the data
dbpath=/var/lib/mongodb
Now, based on mongodb doc:
The default path is[should be]
/data/db
directory, but if the folder isn't present, mongodb will fire from the path given in the mongodb.conf file.
What to do:
- stop your mongodb.
- create your default data folder.
- restart mongodb: this time it will start from the data folder you created.