Unable to list dbs, after creating user in Config Lab

Hi All,

Right after, you create the user ‘m103-admin’, i’m not able to see the dbs
I have validated the lab and got it correct, but this i couldn’t understand… someone please explain.

MongoDB Enterprise > show dbs
2019-05-18T09:35:06.639+0000 E QUERY [thread1] Error: listDatabases failed:{
“ok” : 0,
“errmsg” : “there are no users authenticated”,
“code” : 13,
“codeName” : “Unauthorized”
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:67:1
shellHelper.show@src/mongo/shell/utils.js:860:19
shellHelper@src/mongo/shell/utils.js:750:15
@(shellhelp2):1:1

Thanks,
Rahul

You have provided admin rights to user “m103-admin”.
You will need to log into mongo shell via this new user to see the dbs.

This is because you have enabled authentication, and now already created your 1st user “m103-admin”.

Try logging in with m103-admin and you should be able to fire “show dbs” successfully.

same error when i login with “m103-admin” but with admin i’m able to…

vagrant@m103:~$ mongo admin -port 27000
MongoDB Enterprise > show dbs
2019-05-18T10:05:08.255+0000 E QUERY [thread1] Error: listDatabases failed:{
“ok” : 0,
“errmsg” : “there are no users authenticated”,
“code” : 13,
“codeName” : “Unauthorized”
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:67:1
shellHelper.show@src/mongo/shell/utils.js:860:19
shellHelper@src/mongo/shell/utils.js:750:15
@(shellhelp2):1:1
MongoDB Enterprise > db.auth(“m103-admin”, “m103-pass”)
1
MongoDB Enterprise > db.getUsers()
[
{
“_id” : “admin.m103-admin”,
“user” : “m103-admin”,
“db” : “admin”,
“roles” : [
{
“role” : “root”,
“db” : “admin”
}
]
}
]
MongoDB Enterprise > show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
MongoDB Enterprise >

=====LOG======
2019-05-18T10:05:01.829+0000 I NETWORK [listener] connection accepted from 127.0.0.1:40555 #8 (1 connection now open)

2019-05-18T10:05:01.829+0000 I NETWORK [conn8] received client metadata from 127.0.0.1:40555 conn8: { application: { name: “MongoDB Shell” }, driver: { name: “MongoDB Internal Client”, version: “3.6.12” }, os: { type: “Linux”, name: “Ubuntu”, architecture: “x86_64”, version: “14.04” } }

2019-05-18T10:05:24.152+0000 I ACCESS [conn8] Successfully authenticated as principal m103-admin on admin

What I meant was, once you were able to create the user, you should log into mongo shell, by providing the newly created user and its corresponding password, by using the -u and -p options as follows:

mongo admin --port 27000 -u “m103-admin” -p "m103-pass"

From your message, I can see that you are not providing the username / password

vagrant@m103:~$ mongo admin -port 27000