Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify a relative db path for storing mongodb's data?

I'd like to use a relative path for mongodb, so that each user has a separate data directory when running mongo.

I've tried setting

dbpath = ~/mongodb_data

in my config file, but for some reason that doesn't seem to work - I'm getting:

ERROR: dbpath (~/mongodb_data) does not exist.

At first I thought it might be a permissions error, but I'm running mongod under a user that has rw to ~/mongodb_data.

Is what I'm trying to do feasible, and, if so, how do I get to doing it?

like image 993
blueberryfields Avatar asked Apr 02 '13 16:04

blueberryfields


People also ask

What is path in MongoDB?

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.

Where is mongod conf file located?

For example, for Ubuntu this would be `/etc/mongod. conf` if you installed from the official MongoDB packages. Also is there a mongo command to give me the current path of the db (or config file). The default dbpath is /data/db.

Where are MongoDB databases stored Windows?

MongoDB requires a data folder to store its files. The default location for the MongoDB data directory is c:\data\db. So you need to create this folder using the Command Prompt.

Which parameter in MongoDB output is used to store config file?

dbPath is /var/lib/mongodb; this setting specifies where MongoDB should store its files. systemLog. path is /var/log/mongodb/mongod. log; this is the path where mongod will write its output.


1 Answers

Hello blueberryfields,

I was able to do that just like that on my windows machine:

mongod --dbpath ..\..\data\db

You can use a symbolic link as well.

But as already mentioned, a update on users start up script is the best manageable solution.

like image 133
Moacy Barros Avatar answered Oct 27 '22 10:10

Moacy Barros