Question

I'm using mongodb on 64Bit and 32Bit Linux servers with same configuration, where the option auth=true is set in both config files.

While the 64Bit system required an authentication to run commands like show users or show collections, the 32Bit version gives you all the requested informations without running db.auth() before.

It looks like, the 32 Bit version ignores the auth=true option at the config file.

So: how can I enable auth for mongodb running on an 32Bit system?

Was it helpful?

Solution

The 32bit version should support authentication just fine. But it is possible that:

  • It uses a different configuration file (use: -f /etc/mongodb.conf as option when starting MongoDB) or you can specify --auth on the command line
  • Because the databases are empty and no user is setup at all, authentication is not required. As soon as you add a user, it will then require db.auth().
  • You don't have a user on the admin database defined. Without this, you can always connect on localhost.

OTHER TIPS

The point is, that authentication is disabled because there is no db users added, only users for a specific database. Connecting to this database using localhost results in an "auth"-free environment. (see for this also the answer from @Derick which point to a possible reason.)

To come back to the question:

So: how can I enable auth for mongodb running on an 32Bit system?

The point is: the auth is active, but not for connects from localhost. To enable auth for connects from localhost, the following startup option is needed:

enableLocalhostAuthBypass=0

I finished this,the role is necessary

db.createUser(
   {
user: "youloginname",
pwd: "123456",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top