2

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
sznrbrt
  • 993
  • 2
  • 11
  • 32
  • 1
    Well you should be wary of "self answers" and particularly ones with no votes at all. The "service" actually runs a "script" which specifies picking up the config file with the config option, so you cannot "pass options" to that. If you want to start your `mongod` instance without authentication, then stop the service and start the instance manually `mongod --dbpath --port ` specifying only the options you want. You can of course read what the current options are in the config file. But "services" don't have command line options other than the basic service control – Neil Lunn Apr 27 '18 at 22:26
  • 1
    https://dba.stackexchange.com/questions/62976/how-can-i-enter-mongo-as-a-superuser-or-reset-users - which should also indicate to you that you are asking on the wrong site – Neil Lunn Apr 27 '18 at 22:27
  • right. thanks! helped me to figure out. For my current testing purposes in local its enough if I can opt out the auth for the brew service by specifying it in the YAML config file. In production its a totally different cup of tea... – sznrbrt Apr 28 '18 at 02:21

0 Answers0