For some reason, I cannot authenticate with a new user in a new database in a Mongo instance that I'm currently connected with using another account on an old database. For instance, I can login with "dbadmin" to "db1" fine, but when I created a new database "newdb" I cannot login with a newly created account.
Here are the steps I followed to create the account:
mongo mongodev01.example.com/admin -u admin -p [password]
This admin account has the following roles: userAdminAnyDatabase, dbAdminAnyDatabase, and readWriteAnyDatabase.
At the DB prompt I issued the following:
use newdb
db.createUser({"user":"newadmin", "pwd": "asdfqwer", "roles":["readWrite"]})
I used show users
and saw the account created in this database with the readWrite role:
> show users
{
"_id" : "newdb.newadmin",
"user" : "newadmin",
"db" : "newdb",
"roles" : [
{
"role" : "readWrite",
"db" : "newdb"
}
]
}
I then restarted the mongod
instance but when I tried to log in remotely (local works fine), I got "authorization failed" even though I had cut-and-pasted the password I used to create the user in the first place. Any ideas?
$ mongo mameteordev01.example.com/db1 -u dbamdin -p
MongoDB shell version: 2.6.4
Enter password:
connecting to: mamongodev01.example.com/db1
> exit
bye
$ mongo mamongodev01.example.com/newdb -u newadmin -p
MongoDB shell version: 2.6.4
Enter password:
connecting to: mamongodev01.example.com/newdb
2014-11-06T20:32:25.676-0800 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1210
exception: login failed