change user mongod is running under in ubuntu
MongoDB adds a user and group, mongodb
, that runs the process and owns the associated files such as logs in /var/log/mongodb and database files in /var/lib/mongodb
If you look in /etc/init.d/mongodb you will see DAEMONUSER=${DAEMONUSER:-mongodb}
- here is where you can change the user running mongod.
You will need to add a user and group, for your new daemon user, as well as chown'ing the files to your new user and group. I wouldn't recommend changing the user, however.
Is there a particular reason that you want to change this user to be something you defined yourself?
Tyler Jones
Updated on July 02, 2022Comments
-
Tyler Jones almost 2 years
I have followed the instructions for installing MongoDB through apt-get, from this page: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
This creates a config file called: /etc/mongodb.conf
And a control script called: /etc/init.d/mongodb
These allow me to start mongodb by calling:
sudo service mongodb start
My question is, how do I change the user the mongod process is running under? I've searched the config file, and the control script and neither have any mention of a user. I had to use
ps aux | less
to see all the processes and find the mongod process to see what user the process was running under. The call to start doesn't accept a user, and the config file doesn't specify a user, and the control script doesn't either. Does anyone have any idea how to change the user or even how the user to run the process under is being determined? -
Tyler Jones about 11 yearsThis is all I needed to know! I was wanting to use the user I had defined already, but I have just assigned all the same permissions to the mongodb user that I needed. Thanks for the info!
-
twiz almost 9 yearsAn item on MongoDB's security checklist is: Run MongoDB with a Dedicated User Is this default user setup good enough to meet that requirement?
-
Forivin over 6 yearsFor debian wheezy it was
/etc/init.d/mongod
not/etc/init.d/mongodb
!