Reputation: 7097
I would like to be able to access mongodb://admin:password@db:27017/testdb
, but I keep getting
Command: ./node_modules/east/bin/east migrate --adapter east-mongo --url mongodb://admin:password@db/testdb
[conn7] SCRAM-SHA-1 authentication failed for admin on testdb from client 172.17.2.60 ; UserNotFound Could not find user admin@testdb
db
is the hostname. This is what I have done:
mongod --storageEngine wiredTiger --httpinterface --rest --master --auth &
mongo admin --eval "db.createUser({user: 'admin', pwd: 'password', roles:[{role:'root',db:'admin'}]});"
If I do
mongo admin -u admin -p password --host db --port 27017
then show dbs
works.
Now I want to access testdb
which I haven't created yet, but from my understanding databases that doesn't exist are created on the fly?
mongo testdb -u admin -p password --host localhost --port 27017
2016-06-08T16:14:02.146+0200 E QUERY Error: 18 Authentication failed.
Question
Can anyone see why I can't connect?
Upvotes: 3
Views: 8067
Reputation: 11162
You are trying to authenticate against a database that is non-existent or empty. This is why the authentication fails.
I would
use testdb
to switch to testdb databasedb.createuser(...)
with the appropriate options to create a user/password which you can use to authenticate withThen you should be able to do what you described.
Upvotes: 5