Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change user mongod is running under in ubuntu

Tags:

mongodb

ubuntu

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?

like image 661
Tyler Jones Avatar asked Feb 23 '13 17:02

Tyler Jones


People also ask

Where is MongoDB installed in Ubuntu?

Step 2: Installing MongoDB Database on Ubuntu During the MongoDB installation, it will create the configuration file /etc/mongod. conf , data directory /var/lib/mongodb and the log directory /var/log/mongodb . By default, MongoDB runs using the mongodb user account.

Does MongoDB work in Ubuntu?

MongoDB can be installed on Ubuntu with the use of the following commands. These commands are easy to run on the terminal and make the installation process handy. Follow the steps given below to install MongoDB: Step 1: First you need to update and upgrade your system repository in order to install MongoDB.


1 Answers

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?

like image 189
Nick Avatar answered Oct 08 '22 09:10

Nick