I tried mongod --dbpath=/data
option to change the data directory location, by executing this command continously running in forground waiting for connection
it works on mongo CLI, But after I stop the mongod --dbpath=/data
by CTRL +C, mongo CLI refuse to Connect
Then After restarting mongod service, it's just normally use by default path in root directory.
Then I edited in /etc/mongodb.conf db path parameter, after mongob serive can't start
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: Active: failed (Result: exit-code) since Mon 2019-07-15 19:36:47 IST; 5s ago Docs: https://docs.mongodb.org/manual Process: 5355 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited Main PID: 5355 (code=exited, status=2)
How do I make this permanent
**I change that new directory ownership to mongodb user **I am using Ubuntu
dbPath
in your configuration path (/etc/mongod.conf
according to your service message would be the right place to persist the change. If you review the MongoDB log file (as persystemLog.path
in the config file), there should be more context on the startup error. I would check that directory and file permissions are correct for thedbPath
and log path. If you are still having issues, please edit your question to include details of the startup error from the MongoDB server log.