Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB Path Change?

Tags:

mongodb

My server went down from an electrical failure and for a few horrifying seconds, I thought I'd lost all MongoDB data. I then realized that when the server restarted, mongo automatically restarted without the --dbpath option.

What I can't figure out is why, even though my mongodb.conf has the dbpath set to /var/lib/mongodb, mongo looked for the db files in /data/db on startup. Can anyone shed some light on this?

Thanks!

like image 408
Calvin Froedge Avatar asked Oct 17 '11 20:10

Calvin Froedge


People also ask

What is dbPath in MongoDB?

If you want mongod to store data files at a path other than /data/db you can specify a dbPath . The dbPath must exist before you start mongod . If it does not exist, create the directory and the permissions so that mongod can read and write data to this path.


1 Answers

/data/db is the default path that mongod will look for data files in if it is started with no options. Does your startup script instruct mongod to load the correct config file? If not, that would explain this behavior.

like image 166
dcrosta Avatar answered Sep 20 '22 14:09

dcrosta