Mongodb – what is the password to user mongodb when mongodb is installed in ubuntu

mongodbpermissionsUbuntu

When I installed mongodb in ubuntu, user mongodb and group mongodb are created in /etc/passwd and /etc/group. But I have no idea of the password to these user and group. I have to run mongod as root user, which is not suggested. Someone suggests to change the owner of mongodb data and log files to mongodb:mongodb. But I have no idea how to run mongod as mongod?
Any idea?

Best Answer

Launch Shell as User:

If all else fails, on Ubuntu 14.04 LTS running on AWS, try this...

me@local $ ssh -i aws.pem ubuntu@foo
ubuntu@foo $ sudo -u mongodb bash   # OR whatever shell (zsh)
mongodb@foo $ mongod --dbpath /data/db --fork

OF COURSE, you'll add a much larger set of flags to the command. Note also that this assumes you're authenticated as ubuntu on an AWS EC2 instance. The first portion of each line to the left of the $ is the user@hostname

Invoke Command as User:

YMMV but this should work too...

mongodb@foo $ sudo -u mongodb mongod --dbpath /data/db --fork