admin中加的帐号是admin/admin
test中加的帐号是test/test
这也就意味着admin是超级帐号可以访问test db ,但是auth返回的是false
用test认证boolean auth = db.authenticate("test", "test".toCharArray());返回是true但是下面报错还是一样的。
Exception in thread "main" com.mongodb.CommandResult$CommandFailure: command failed [listDatabases]: { "serverUsed" : "/127.0.0.1:27017" , "errmsg" : "need to login" , "ok" : 0.0}
at com.mongodb.CommandResult.getException(CommandResult.java:88)
at com.mongodb.CommandResult.throwOnError(CommandResult.java:134)
at com.mongodb.Mongo.getDatabaseNames(Mongo.java:374)
at nosql.Mogobean.main(Mogobean.java:73)
|