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!
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.
/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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With