Is there any MongoDB command that will display information about my current connection after I connected to the database, i.e. username, database and hostt that I am connected to?
I found db.currentOp() but this list all sessions. There is also db.hostInfo() but I am just after the hostname. I can’t find one for the current user that I am login as. My version from db.version() shows 3.2.7.
Hostname is available from db.hostInfo() on v3.2 as shown here. I am not sure there’s much available via the mongo shell itself. You can find any available here. You may also be able to see connection info with db.getMongo().
There’s also getHostName() which is a native method that the shell supports. You can also loosely determine the operating system type with _isWindows()
Thanks for your reply.
Turns out a simple hostname() will do and db will show the database that I am connected to.
So, now am just running db or hostname() to check.
There doesn’t appear to be an option to check who I am login as, do you know of any?
Basically, I want to check who am I when I am connected to the database?
Something like db.runCommand({connectionStatus : 1}) or any command as plain as showing just the user account