MongoDB not using /etc/mongodb.conf after I changed dbpath

mongodb

Solution

It turns out that I needed to set the owner and group to `mongodb`. When I transferred the files to the new directory, I had set the owner and group to my user account `nick` and also tried `root`, neither of which worked.

To do so, here are the following commands:

sudo chown mongodb /home/nick/appdev/mongodb -R
sudo chgrp mongodb /home/nick/appdev/mongodb -R

To confirm that it worked, you can check the file permissions with:

ls -l /home/nick/appdev/mongodb

Problem

Ever since I changed the `dbpath` in `/etc/mongodb.conf`, MongoDB has not been starting automatically, nor using the new `dbpath`. Prior to the change, MongoDB would be running when the computer started and I was able to simply run the command `mongo` to get into the console or start my Ruby on Rails server with no issues. After I made the modification (in order to switch to a new drive with more space), the only way I can get everything to work is by manually running the command `mongod --config /etc/mongodb.conf`. If I don't run that, it doesn't seem like the service is running and running without the `--config` option give me the following error: `ERROR: dbpath (/data/db/) does not exist.` even though the config file says nothing about `data/db`. Some other notes: - In addition to changing `/etc/mongodb.conf`, I moved all files out of `/var/lib/mongodb` and into `/home/nick/appdev/mongodb`. - I changed the owner and group from `root` to `nick`. Tried changing it back, but it didn't seem to fix anything. - I'm running Ubuntu 12.10 Beta 1 and Mongo 2.2.0 with Ruby on Rails 3.2.8

Original source