First, let's get a tan. Log logs error message
2016-07-13t22:19:43.667+0800 I ACCESS [CONN4] Authenticate Db:finddemo {authenticate:1, nonce: "xxx", User: "User1", Key: "xxx"}2016-07-13t22:19:43.668+0800 I ACCESS [CONN4] Failed to authenticate [Email protected]ddemo with Mecha Nism mongodb-cr:authenticationfailed:usernotfound:could not find User [email protected]2016-07-13t22:20:12.555 +0800 I ACCESS [CONN2] scram-sha-1 authentication failed for User1 on Finddemo from client 127.0.0.1; Usernotfound:could not find User [email protected]2016-07-13t22:20:17.127+0800 I NETWORK [Initandlisten] Connection accepted from 127.0.0.1:56103 #5 (4 connections now OPEN) 2016-07-13t22:20:17.127+0800 I ACCESS [Conn5] Authe Nticate db:admin {authenticate:1, nonce: "xxx", User: "Root", Key: "xxx"}2016-07-13t22:20:17.146+0800 I NETWORK [init Andlisten] Connection accepted from 127.0.0.1:56104 #6 (5 connections now OPEN) 2016-07-13t22:20:17.146+0800 I ACCESS [Co NN6] Authenticate db:admin {authenticate:1, nonce:"XXX", User: "Root", Key: "XXX"}
Focus on this error message,
Scram-sha-1 authentication failed for User1 on Finddemo
What kind of bird is this?
MongoDB joins the Scram-sha-1 verification method, requires a third-party tool to be validated, the following specific solutions:
First turn off authentication, modify the System.version document inside the Authschema version is 3, the initial installation should be 5, the command line as follows:
>Use Admin switched to DB admin>varSchema = Db.system.version.findOne ({"_id":"Authschema"}) > schema.currentversion =3 3>Db.system.version.save (Schema) Writeresult ({"nmatched":1,"nupserted":0,"nmodified":1})
The following is information about the user that was obtained
{"_id":"Admin.root","User":"Root","DB":"Admin","Credentials": {"MONGODB-CR":"97a156792bd180dc82cec9a56d838991"},"Roles": [ {"role":"__system","DB":"Admin" } ] }{ "_id":"Finddemo.finddemo","User":"Finddemo","DB":"Finddemo","Credentials": {"MONGODB-CR":"4b8dce39de95d553473c1998f43aa165"},"Roles": [ {"role":"Dbowner","DB":"Finddemo"} ] }
Reconnect, success.
You can check the link description:
https://docs.mongodb.com/master/release-notes/3.0-scram/
And the answer of foreign friends: (More and more despise Baidu Party)
Http://stackoverflow.com/questions/29006887/mongodb-cr-authentication-failed
MongoDB non-admin library Authentication login Failure Reason (Baidu is a lot of slag) Db.adduser () please go away.