Getting error while doing Ch-1 lab titled "Change the Default DB Path"

So i followed the steps in the lab including sudo and chown, but when i connect to mongo i keep getting following error.

What is wrong here ?

below is listing from /var directory
vagrant@m103:/var/mongodb$ ls -ltr
total 8
drwxr-xr-x 2 vagrant vagrant 4096 Dec 10 02:45 log
drwxr-xr-x 4 vagrant vagrant 4096 Dec 10 02:47 db

Below is section from config file
storage:
dbPath: /var/mongodb/db/
systemLog:
destination: file
path: /var/mongodb/log/mongod.log

errorlog states below line/s
2019-12-10T03:02:07.569+0000 I ACCESS [conn2] Unauthorized: not authorized on admin to execute command { getLog: “startupWarnings”, lsid: { id: UUID(“e4363a96-20cb-48b9-81b2-a9f60b6f235e”) }, $db: “admin” }
2019-12-10T03:02:07.570+0000 I ACCESS [conn2] Unauthorized: not authorized on admin to execute command { getCmdLineOpts: 1.0, lsid: { id: UUID(“e4363a96-20cb-48b9-81b2-a9f60b6f235e”) }, $db: “admin” }
2019-12-10T03:02:22.277+0000 I ACCESS [conn2] Unauthorized: not authorized on admin to execute command { listDatabases: 1.0, lsid: { id: UUID(“e4363a96-20cb-48b9-81b2-a9f60b6f235e”) }, $db: “admin” }
2019-12-10T03:02:40.063+0000 I NETWORK [conn2] end connection 127.0.0.1:34578 (0 connections now open)

And below is error i see within mongo shell :-1:
vagrant@m103:~$ mongo --port 27000
MongoDB shell version v3.6.16
connecting to: mongodb://127.0.0.1:27000/?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“e4363a96-20cb-48b9-81b2-a9f60b6f235e”) }
MongoDB server version: 3.6.16
MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > show dbs
2019-12-10T03:02:22.278+0000 E QUERY [thread1] Error: listDatabases failed:{

  •    "ok" : 0,*
    
  •    "errmsg" : "not authorized on admin to execute command { listDatabases: 1.0, lsid: { id: UUID(\"e4363a96-20cb-48b9-81b2-a9f60b6f235e\") }, $db: \"admin\" }",*
    
  •    "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 > quit()

i am just trying to go ahead and create the user in the admin db and hitting this hurdle.

Would appreiate feedback.

TIA

Samir

Based on your config file, the authentication enabled option stops you from performing any useful operations besides creating the first user.

So go ahead and create the root user on the admin db, login using those credentials and you’ll be able to show dbs.

Hi @Samir_29862,

You cannot perform any action until you create the first user and authenticate against that user.

You can create the first user on the admin db using the localhost exception. You should not get any error in doing this if the syntax are correct.

Let me know if the issue still persists.

Thanks,
Shubham Ranjan
Curriculum Support Engineer