Add to ~/.mongorc.js:
~/.mongorc.js
db = connect('localhost:27017/<authentication database>'); db.auth('<admin>', '<password>');
stackoverflow.com/a/47894057