0

I have a ReplicaSet in which I created a user like this:

db.createUser({ 
    user: "myuser", 
    pwd:"mypassword", 
    roles: [  
        {
        role: "userAdminAnyDatabase", 
        db: "admin" 
        }, 
        { 
        role: "dbAdminAnyDatabase", 
        db: "admin" 
        },  
        { 
        role: "readWriteAnyDatabase", 
        db:"admin" 
        },  
        { 
        role: "clusterAdmin", 
        db: "admin" 
        }
    ]});

When I activate then authorization in my config file like this:

security:
  authorization: enabled
  keyFile: /my/file.key

I restart replicaset nodes and try to connect using :

mongo mongodb://myuser:mypassword@host1:port,host2:port,host3:port/?replicaSet=myReplicaName&authSource=myDbName

I get Error: can't connect to new replica set master [ip:port], err: AuthenticationFailed: Authentication failed.

Any idea what could be missing?

Monta
  • 1,136
  • 1
  • 12
  • 28

0 Answers0