mongo user can not connect from bash on localhost
MongoDB auth setting is false as a default.
First of all, you should create the root user.
//create new user with the root role (also, named root):
use admin
db.createUser({
  user: &quot;root&quot;,
  pwd: &quot;pass&quot;,
  roles : [ &quot;root&quot; ]
})

After that, you should start your mongod service with the auth option, it means authentication is enabled.
mongod --auth

Also, you can add your mongod.conf file this parameter :
security:
    authorization: enabled

And start your mongod with the command which is below.
mongod --config /etc/mongod.conf //your mongod.conf path

Check this out for more info.