Can't connect with any user to any db

Hi!

first of all, i am a completely newbie whit mongo and kubernetes. Sorry if i miss important info!

I installed all using this manual Generic Kubernetes installation - Percona Operator for MongoDB

I only change, cluster name from my-cluster-name on avery *.yaml file to mongo-bo. Also, i change passwords on secrets.yaml and from cr.yaml the option to make a load balancer.

I ended installation with no errors, load balancer works fine, i can access from an external computer using mongo --host xx.xx.xx.xx

But when i tried to list dbs, i get this error
mongos> use admin
switched to db admin
mongos> show users
2022-03-18T09:05:05.582+0100 E QUERY [thread1] Error: command usersInfo requires authentication :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.getUsers@src/mongo/shell/db.js:1523:1
shellHelper.show@src/mongo/shell/utils.js:744:9
shellHelper@src/mongo/shell/utils.js:651:15
@(shellhelp2):1:1

if i use mongo --host xx.xx.xx.xx -u userAdmin -p anypassword
mongo ask me again form password. But i can write anything, rigth password or ramdom characters and always get the same error

$ mongo -host XX.XX.XX.XX -u useradmin -p asdasdas
MongoDB shell version: 3.2.11
Enter password:
connecting to: XX.XX.XX.XX:27017/asdasdas
2022-03-18T09:07:13.209+0100 E QUERY [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1441:20
@(auth):6:1
@(auth):1:2

exception: login failed

and finally i found this part of manual, Application and system users - Percona Operator for MongoDB

i can start percona-client, but i cant connect

kubectl run -i --rm --tty percona-client --image=percona/percona-server-mongodb:4.4.10-11 --restart=Never – bash -il

percona-client:/$ mongo “mongodb://userAdmin:userAdmin123456@my-cluster-name-mongos..svc.cluster.local/admin?ssl=false”
If you don’t see a command prompt, try pressing enter.
[mongodb@percona-client /]$ mongo
Percona Server for MongoDB shell version v4.4.10-11
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

don’t matter which user/pass i use.

Any help please???

Thanks in advance

1 Like

Hello @jpuntas ,

we create two system users that you can use to connect to MongoDB and do something:

userAdmin can create new users granting access to databases and other magic.

About connecting to DB, first of I see the typo in here:

percona-client:/$ mongo “mongodb://userAdmin:userAdmin123456@my-cluster-name-mongos..svc.cluster.local/admin?ssl=false”

I think you skipped the namespace and also should use your cluster name (is it mongo-bo)?. So it should be something like this for default namespace:

percona-client:/$ mongo “mongodb://userAdmin:userAdmin123456@mongo-bo-mongos.default.svc.cluster.local/admin?ssl=false”

If it does not help - please show me your kubectl get services and I will try to help more.

1 Like