Reputation: 1343
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?
Upvotes: 6
Views: 19174
Reputation: 1554
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?
Upvotes: 15