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?
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
The MongoDB user might have been created to be able to access services. Should using root username not be recommended, may I recommend that you create an admin user on your mongodb database? See how to do that in the MongoDB documentation:
Since you are able to access the database using the root username, creating an admin account will allow you to modify the mongodb user's password.
I encountered this issue with SQL Server in the past. Modifying the service account was what was required.