Run MongoDB 3.6 as a brew service with auth

2.5k views Asked by At

MongoDB v3.6.4: After migrating from mongo 3.4 to 3.6

From the shell I am able to startup the db and connect to it with authentication.

mongod --auth --port 27017 --dbpath /data/db

However when I start mongodb with brew the authentication does not work and it is not possible to authenticate manually either.

~   $ mongo
MongoDB shell version v3.6.4
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.4
> use admin
switched to db admin
> db.stats()
{
    "ok" : 0,
    "errmsg" : "not authorized on admin to execute command { dbstats: 1.0, scale: undefined, $db: \"admin\" }",
    "code" : 13,
    "codeName" : "Unauthorized"
}
> db.auth('superAdmin', 'password')
Error: Authentication failed.
0

How is it possible to run mongodb as a service with auth?

It is possible to opt-out authentication by setting authorization to disabled in the /usr/local/etc/mongod.conf file however it would be nice to run the service with the required priviliages:

security:
  authorization: disabled

Done, checked:

  1. The answer suggested here does not seem to be correct either - it is not a valid commandbrew services start mongodb --auth --port 27017 --dbpath /usr/local/var/mongodb
0

There are 0 answers