Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I had a mongodb ,and a database named genbank ,genbank has a user whose role is "read" and "readAnyDatabase",it is very strange that I cannot connect genbank through this role by MongoVUE ,but I can connect successfully under administrator role.

The connection configuration is :

enter image description here

genbankReader is the username for genbank database.

the error message is :

Unable to connect to server *.*.*.*:40000: Invalid credential for database 'admin'..
Type: MongoDB.Driver.MongoConnectionException
Stack:    在 MongoDB.Driver.Internal.DirectMongoServerProxy.Connect(TimeSpan timeout, ReadPreference readPreference)
   在 MongoDB.Driver.MongoServer.Connect(TimeSpan timeout)
   在 MongoDB.Driver.MongoServer.Connect()
   在 MangoUI.MMongo.m7FnMeKibMFwcOmRDx4q(Object )
   在 MangoUI.MMongo.Open(Boolean useSamus)
   在 MangoUI.MMongo.Open()
   在 MangoUI.ComNavTree.d0Pck1r6Vh91JYOyd29(Object )
   在 MangoUI.ComNavTree.ExpandMe(MTreeNode expand)
   在 MangoUI.ComNavTree.tree_BeforeExpand(Object sender, TreeViewCancelEventArgs e)


Invalid credential for database 'admin'.
Type: MongoDB.Driver.MongoAuthenticationException
Stack:    在 MongoDB.Driver.Communication.Security.MongoCRAuthenticationProtocol.Authenticate(MongoConnection connection, MongoCredential credential)
   在 MongoDB.Driver.Communication.Security.Authenticator.Authenticate(MongoCredential credential)
   在 MongoDB.Driver.Communication.Security.Authenticator.Authenticate()
   在 MongoDB.Driver.Internal.MongoConnection.Open()
   在 MongoDB.Driver.Internal.MongoConnection.GetNetworkStream()
   在 MongoDB.Driver.Internal.MongoConnection.SendMessage(BsonBuffer buffer, MongoRequestMessage message, WriteConcern writeConcern, String databaseName)
   在 MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage message, WriteConcern writeConcern, String databaseName)
   在 MongoDB.Driver.Internal.MongoConnection.RunCommandAs[TCommandResult](String databaseName, QueryFlags queryFlags, CommandDocument command, IBsonSerializer commandResultSerializer, IBsonSerializationOptions commandResultSerializationOptions, Boolean throwOnError)
   在 MongoDB.Driver.Internal.MongoConnection.RunCommandAs[TCommandResult](String databaseName, QueryFlags queryFlags, CommandDocument command, Boolean throwOnError)
   在 MongoDB.Driver.MongoServerInstance.Ping(MongoConnection connection)
   在 MongoDB.Driver.MongoServerInstance.Connect()
   在 MongoDB.Driver.Internal.DirectMongoServerProxy.Connect(TimeSpan timeout, ReadPreference readPreference)


Command 'authenticate' failed: auth fails (response: { "code" : 18, "ok" : 0.0, "errmsg" : "auth fails" })
Type: MongoDB.Driver.MongoCommandException
Stack: 
Inputs:: 
Command:  authenticate
Ok:       False
ErrorMsg: auth fails
Request:  { "authenticate" : 1, "user" : "genbankReader", "nonce" : "264abe28fc4dd95", "key" : "ca2124ded060247d527941e55820fd80" }
Response: { "code" : 18, "ok" : 0.0, "errmsg" : "auth fails" }

Since my db user always use mongoVUE but I cannot give him other privilege except for read .So ,any one can help me solve my problem?

share|improve this question
    
Can you show an example of successfully logging in with the genbankReader user with the mongo shell for that database? It looks like auth is simply failing, so the most common causes would be that the user does not exist in that database context, or your password is incorrect. –  Adam C Jan 25 at 3:12

1 Answer 1

Your error looks like a standard "auth failed" exception... If all the parameters of your connection are correct for your setup, I'd suggest you try to logon from the mongo shell directly: $>mongo 1.2.3.4:40000/genbank -u genBankReader -p passwd1234 --authenticationDatabase admin --verbose Use the --verbose flag to log on as both the "read-only" user and the "admin" user and see if you can tell more of what's wrong (if any).

Alternative you can use another mongo client GUI like Robomongo and see if that works. (I used to use MongoVue but switched to Robomongo as it was less confusing and more shell-oriented)

Otherwise, you could have setup/added the users incorrectly. Use the admin user to check db.system.users collection of the proper database just to make sure. Perhaps take another look at http://docs.mongodb.org/manual/reference/privilege-documents/

Hope this helps, good luck

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.