I am working on a Scala framework that wants to connect to a local instance of MongoDB using the Mongo Java library, but does not work. The URI that it uses to connect is:
mongodb://user: pass@localhost :27017/mydb
When you try to update a collection, the following exception occurs:
com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "auth failed" , "code" : 18}
However, if I extract the parameters from the URI and pass them to the Mongo shell:
$ mongo -u user -p pass --host localhost --port 27017 mydb
... then he lets me! Can anyone guess why this might be?
Perhaps, but it is unlikely to matter: everything works fine in the original environment in which I ran my infrastructure, a Dell laptop running Ubuntu. Now I'm trying to run it on a Mac laptop running Ubuntu in Virtualbox. Everything should be practically (ha) the same, but obviously this is not so.
source share