0

I want to run mongodb service by my defined username and group instead of using mongodb user. How can i change from mongodb user to mydesiredusername?

1

If you're running mongodb as a service, you would need to edit the upstart configuration file:

  1. Edit /etc/init/mongodb.conf.
  2. Change the argument --chuid mongodb to --chuid mydesiredusername. If you need to specify a group, use --chuid mydesiredusername:mydesiredgroup.
  3. Restart by running sudo restart mongodb.

You might also need to change the ownership of your database files (in /var/lib/mongodb unless you have changed that as well) and the /var/log/mongodb directory and its contents so that mongodb can still read and write to its files.

You don't explain why you want to make this change, so maybe you have a good reason. But I would suggest keeping to the default user and finding an alternative solution to the problem you are trying to solve. Services run as their own user for good reasons, not least for security. Changing something like this can cause unexpected problems in the future, make upgrades harder, and is also confusing if other people need to administer your server at a later date.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.