how to set mongod --dbpath
First you will have a config file in /etc/mongodb.conf
, therefore this sounds like a homebrew install which will use some more standardized paths. The whole /data/db/
thing is referenced in a lot of manual install documentation.
So basically from your log the server is not running, it's shutting down, so there is nothing for the shell to connect to. Seems like you have had some unclean shutdowns/restarts which has led to the inconsistency.
Clear the files in the journal /usr/local/var/mongodb/journal/
on your config.
Also:
sudo rm /var/lib/mongodb/mongod.lock
Just in case, even though that part looks clean. And then restart.
You can set dbPath in the mongodb.conf file:
storage:
dbPath: "/path/to/your/database/data/db"
It's a YAML-based configuration file format (since Mongodb 2.6 version), so pay attention no tabs only spaces, and space after ": "
usually this file located in the *nix systems here: /etc/mongodb.conf
So then just run
$ mongod -f /etc/mongodb.conf
And mongod process will start...
(on the Windows something like)
> C:\MongoDB\bin\mongod.exe -f C:\MongoDB\mongod.conf
For me it must have:
mongod --dbpath=/whatever/data/path
Have only tried this on Mac:
- Create a data directory in the root folder of your app
- cd into your wherever you placed your mongo directory when you installed it
run this command:
mongod --dbpath ~/path/to/your/app/data
You should be good to go!