0

I've created a new user on a clean database, but can't connect with it. I can, however, connect with no credentials.

PS C:\Program Files\MongoDB\Server\3.0\bin> .\mongo.exe localhost/test
MongoDB shell version: 3.0.11
connecting to: localhost/test
> var me = { user: 'dave', pwd: 'password', roles: [ 'userAdminAnyDatabase'] }
> use admin
switched to db admin
> db.createUser(me)
Successfully added user: { "user" : "dave", "roles" : [ "userAdminAnyDatabase" ] }
> ^C
bye
PS C:\Program Files\MongoDB\Server\3.0\bin> .\mongo.exe -u dave -p password
MongoDB shell version: 3.0.11
connecting to: test
2016-04-27T15:40:38.185+0100 E QUERY    Error: 18 Authentication failed.
    at DB._authOrThrow (src/mongo/shell/db.js:1271:32)
    at (auth):6:8
    at (auth):7:2 at src/mongo/shell/db.js:1271
exception: login failed
BanksySan
  • 27,362
  • 33
  • 117
  • 216

1 Answers1

0

I believe that you are connecting to the test database. But the user was created in the admin database.

Try to create the user in test. use test.

Or specify in the login which scheme to connect to

Felipe Sulser
  • 1,185
  • 8
  • 19