edit-icon download-icon

How to deal with logon failure?

Last Updated: Oct 28, 2016

I create an account on a MongoDB instance, and the account name and password are both “test”. The system returns the error “Authentication failed” when I run mongo —host $myhost —port $myport -u test -p test.

The MongoDB account is associated with the database. The database to which the account belongs must be specified during authentication. Assume that the “test” account belongs to the admin database. You can run the following command to log on to the database:

  1. mongo host $myhost port $myport -u test -p test authenticationDatabase admin


  1. mongo host $myhost port $myport
  2. mongo> use admin
  3. mongo> db.auth(“test”, test”)
Thank you! We've received your feedback.