Hi Team,
I have build mongoDB community edition and configured security setting in the DB conf file. After I started MongoDB. I created Admins. Finally tried to create database but getting the below error.
rs0 [direct: primary] admin> >use DBNAME
rs0 [direct: primary] DBNAME> db.student.insertOne({student_id:105,fname:“Rohit”,lname:“Agarwal”,course:“MySQL”})
MongoServerError[Unauthorized]: not authorized on DBName to execute command { insert: “student”, documents: [ { student_id: 105, fname: “Rohit”, lname: “Agarwal”, course: “MySQL”, _id: ObjectId(‘6601a1337d961c6dc1814c42’) } ], ordered: true, lsid: { id: UUID(“ca4bd51d-61c5-4b99-b014-bf184aab992b”) }, txnNumber: 2, $clusterTime: { clusterTime: Timestamp(1711382675, 1), signature: { hash: BinData(0, F7D5E0F5A7642A4D309724DFDFE8D3B3D9044060), keyId: 7346653907562528775 } }, $db: “DBName” }
rs0 [direct: primary] DBNAME>