I'm trying to run mongod with its defaults so it's using the /data/db directory. I changed the owner of the data directory
sudo chown mongodb:mongodb /data -R
Like so many others i got the following error when first running mongod.:
2017-04-11T12:32:25.932-0500 I STORAGE [initandlisten] exception in initAndListen: 28596 Unable to determine status of lock file in the data directory /data/db: boost::filesystem::status: Permission denied: "/data/db/mongod.lock", terminating
Which makes sense but what doesn't make sense is the only way i can actually run it mongod is if i:
chmod 777 /data -R
If i
chmod 666 /data -R
i get the same error. Since this is supposed to be the data directory why does it require execute permission.
i added my user to the mongodb group
sudo usermod -g mongodb myuser
and then i tried
chmod 770 /data -R
and its still failing even through i'm a member of the mongodb group.
Why am i messing with all this? Because i want to secure the data directory appropriately and don't want to have to run with 777 security.
So the questions are:
- Why is execute permission required
- Why am i unable to run it when i was a member of the mongodb group?
sudo chown mongodb:mongodb /data -Rworked ?? Why is-Rflag passed after the path?