Cannot authenticate into mongo, “auth fails”

前端 未结 12 1272
无人及你
无人及你 2020-11-30 21:40

I\'ve created an admin user for mongo using these directions:

http://docs.mongodb.org/manual/tutorial/add-user-administrator/

From the mongo client it looks

12条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 22:17

    In MongoDB 3.0, it now supports multiple authentication mechanisms.

    1. MongoDB Challenge and Response (SCRAM-SHA-1) - default in 3.0
    2. MongoDB Challenge and Response (MONGODB-CR) - previous default (< 3.0)

    If you started with a new 3.0 database with new users created, they would have been created using SCRAM-SHA-1.

    So you will need a driver capable of that authentication:

    http://docs.mongodb.org/manual/release-notes/3.0-scram/#considerations-scram-sha-1-drivers

    If you had a database upgraded from 2.x with existing user data, they would still be using MONGODB-CR, and the user authentication database would have to be upgraded:

    http://docs.mongodb.org/manual/release-notes/3.0-scram/#upgrade-mongodb-cr-to-scram

    Now, connecting to MongoDB 3.0 with users created with SCRAM-SHA-1 are required to specify the authentication database (via command line mongo client), and using other mechanisms if using a driver.

    $> mongo -u USER -p PASSWORD --authenticationDatabase admin

    In this case, the "admin" database, which is also the default will be used to authenticate.

提交回复
热议问题