I'm more familiar with MySQL, but in my new workplace, I have to look after a MongoDB database (MongoDB 4.2.18 with Mongosh 1.1.9 running on Ubuntu 18.04.6 -- yes, it's old; upgrading is a problem for another day). I don't know anything about MongoDB. Unfortunately, the person who created it has left and left behind no documentation. Now, I need to look after it.
What I have is a username and a password. With that, I can login like so:
mongosh --port 27017 --authenticationDatabase "admin" -u "XXX" -p
I can list all of the databases by doing show databases
. But, I can't execute the command show users
:
admin> show users
MongoServerError: not authorized on admin to execute command { usersInfo: 1, lsid: { id: UUID("b2c4e061-1b54-4b27-bdf2-bef330b38b4d") }, $db: "admin" }
I then tried to get a list of users. And I think this is the command to do it:
admin> show collections
system.users
system.version
admin> db.system.users.find().pretty ()
MongoServerError: not authorized on admin to execute command { find: "system.users", filter: {}, lsid: { id: UUID("1801ce09-5c09-44eb-9b04-86eb35817eaa") }, $db: "admin" }
Together, this feels like my account isn't an administrator's account. Would this be correct?
If so, is it possible to create a new account with full administator's privileges? I have sudo
access on the host machine. If so, how would I do that?
Thank you!