Cannot log in to Mongo from command line - using MongoDB 3.0 and WiredTiger NOTE: I have tried not setting bind_ip and also setting it to 0.0.0.0 -- neither one fixed my issue.

This is my mongod.conf file:

systemLog:
    destination: file
    path: "/root/mongodb.log"
    logAppend: true

net:
    port: 25015

processManagement:
    fork: true

setParameter:
    enableLocalhostAuthBypass: true

storage:
    dbPath: /root/mongo_data
    engine: wiredTiger



The first thing I did was SSH in to the DigitalOcean droplet where it is running and do the following:

mongo --port 25019



I was able to connect, so I know it picked up the options in the mongod.conf file.


The second thing I did was issue the following command:

&gt; use admin;
switched to db admin
&gt; db.createUser(
    {
        user: "siteUserAdmin",
        pwd: "eqt-dfts-mad-ghbr-ovd-g",
        roles: [{role: "userAdminAnyDatabase", db: "admin"}]
    }
)
Successfully added user: {
    "user" : "siteUserAdmin",
    "roles" : [
        {
            "role" : "userAdminAnyDatabase",
            "db" : "admin"
        }
    ]
}



So that was apparently a success!


Next I exited from the mongo shell and then logged in to the mongo shell again as siteUserAdmin with credential from above.
Then I created a user and a database for the app I'm building:

&gt; use MyDatabase;
switched to db MyDatabase
&gt; db.createUser(
    {
        user: "my_user",
        pwd: "cu-npp-re-jpor-mtw-e-s",
        roles: [
            {role: "readWrite", db: "MyDatabase"},
            {role: "dbAdmin", db: "MyDatabase"}
        ]
    }
    )
Successfully added user: {
    "user" : "vantage",
    "roles" : [
        {
            "role" : "readWrite",
            "db" : "AdVantage"
        },
        {
            "role" : "dbAdmin",
            "db" : "AdVantage"
        }
    ]
}



So that was also apparently a success!


I then exited the mongo shell and then logged in to the mongo shell again as my_user with credentials from (4).  I confirmed that I was able to create a collection called demotest in MyDatabase:

&gt; use MyDatabase;
switched to db MyDatabse
&gt; db.createCollection("demotest")
{ "ok" : 1 }
&gt; show collections;
demotest
&gt; show dbs;
MyDatabase 0.000GB
admin      0.000GB
local      0.000GB
&gt; exit
bye



So far so good.


I then switched to a terminal on my local machine.  My goal is to be able to connect to this MongoDB instance from my local machine and from an app that is running somewhere else on the internet.  So I issued the following command on my local machine:

PROMPT&gt; mongo --host 102.216.73.164 -u my_user -p cu-npp-re-jpor-mtw-e-s --authenticationDatabase MyDatabase --port 25019
MongoDB shell version: 2.6.6
connecting to: 102.216.73.164:25019/test
2015-05-13T21:03:18.963-0400 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1210
exception: login failed



Here is what I don't understand:


why did it try to connect to the test database?
why doesn't it work?
I've had the same authentication issue on an MMS deployed db (though it has nothing to do with it).


it tries to connect to /test by default. If you want another database, just specify it, e.g. 102.216.73.164/foo.
upgrade your mongo shell to 3.0.3 (you currently use 2.6.6). That solved the problem for me.