How to find current user in MongoDB

In this article, we will find out the current user that I’m logged into the MongoDB Server. We can get the current user by using the command db.runCommand().

Follow the below steps:

1) Connect to the MongoDB Server:
Syntax:

mongo hostname:27017/database -u madmin -p

mongo 127.0.01:27017/test -u madmin -p

2) Execute the below query in the Mongo Shell.
Continue reading How to find current user in MongoDB