How can I sign into the Mongo shell without showing my password? Everything says to either use
mongo -u user -p password -authenticationDatabase admin
or
mongo
> use admin;
> db.auth('user', 'password')
I don't like either one. The first leaves a command in cmd's history. The second isn't in the history but it still displays on screen in plain text. I tried only specifying a user in hopes I'd get a password prompt that doesn't display characters as I type, but in both cases an error occurs.
Is there a way to sign into Mongo in a way that doesn't put my password on the screen or store it in an insecure file (like a .bat or anything)?
I'm operating in Windows 7.
If you add a flag -p
but you don't specify a password, MongoDB shell will prompt you for a password.
mongo -u user -p --authenticationDatabase admin
The password will be hidden as you type and will not be recorded in the shell history.
mongo admin -u admin -p
works (with the least typing), as noted by Corey.
The 1st "admin" is the database, and the 2nd "admin" is the user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With