Authentication Mechanisms¶
MongoDB supports the following authentication mechanisms:
MongoDB Challenge and Response (MONGODB-CR)
在 3.0 版更改: New challenge-response users created in 3.0 will use SCRAM-SHA-1. If using 2.6 user data, MongoDB 3.0 will continue to use MONGODB-CR.
In addition, MongoDB Enterprise also provides supports for additional mechanisms. See Enterprise Authentication Mechanisms for additional mechanisms available in MongoDB Enterprise.
Default Authentication Mechanism¶
在 3.0 版更改.
MongoDB uses the SCRAM-SHA-1 as the default challenge and response authentication mechanism. Previous versions used MONGODB-CR as the default.
Specify Authentication Mechanism¶
To specify the authentication mechanism to use, set the authenticationMechanisms parameter for mongod and mongos.
Clients specify the authentication mechanism in the db.auth() method. For the mongo shell and the MongoDB tools, you can also specify the authentication mechanism from the command line.