MongoDB shell command line authentication fails
Perhaps different now because of an update since this question was originally answered, but authentication only succeeds when wrapping username/password in double quotes. e.g.,
mongo admin -u "myName" -p "myPassword"
The in-shell authentication performed in your example is against the admin database. The command line posted above does not specify a database and is therefore authenticating against the default database which is test. Try this instead to authenticate via command line against the admin db:
mongo admin -u 'USERNAME' -p 'PASSWORD'
if the server is not on the local host then you can use this:
mongo your_host_name:your_port/admin -u 'USERNAME' -p 'PASSWORD'