Today I’m having trouble starting mongodb service on my machine. After reading the logs I found out it should be a permission issue on the mongodb data folder /var/lib/mongodb/.
After some research I did the following command to change the owner of the /var/lib/mongodb foler:
$ sudo chown -cR mongodb:mongodb /var/lib/mongodb
The result showed that the owner successfully changed to mongodb. But when I went to check the result, the owner remained unchanged:
$ sudo ls -ld /var/lib/mongodb/
drwxr-xr-x 1 root root 0 May 24 11:43 /var/lib/mongodb/
As you can see, the owner of this folder is still root, not mongodb. How is that possible? Is there any other way to do this? Please advise. Thank you.
Best is to copy/paste a little bit more so that it includes the prompt, the command, all output (even if it is nil) and the next prompt. That gives the maximum amount of information to the potential helpers here.
I don’t use mongodb so wouldn’t know off the top of my head how mongodb is set up, but I imagine the permissions on the datafiles should be related to the security context the mongodb app itself is running in…
In other words, if mongodb is set up to run using a mongodb service account, then it makes sense that the datafiles might need to have same security context.
On the other hand, if mongodb is set up to run as a system service, then more than likely the data files should <not> be accessed using a mongodb account (although it’s possible. Practically anything is configurable).
I’d recommend you consult the most current MongoDB documentation available and specifically for your version of MongoDB… and be wary about random fixes you might find on the Internet.
If you installed your MongoDB from openSUSE repos, typically everything should be set up with defaults that should work with official documentation and not require anything like changing permissions on data files.