У меня работает:
Запустил сервер:
$ mongod --auth --dbpath /tmp/1 --smallfiles --port 27020
Добавляю пользователя:
$ mongo --port 27020
MongoDB shell version: 2.6.10
connecting to: 127.0.0.1:27020/test
> show dbs
admin (empty)
local 0.031GB
> use admin
switched to db admin
> db.addUser({user:'name', pwd:'password', roles:["userAdminAnyDatabase","dbAdminAnyDatabase", "readWriteAnyDatabase"]})
WARNING: The 'addUser' shell helper is DEPRECATED. Please use 'createUser' instead
Successfully added user: {
"user" : "name",
"roles" : [
"userAdminAnyDatabase",
"dbAdminAnyDatabase",
"readWriteAnyDatabase"
]
}
> exit
bye
Проверяю:
$ mongo --port 27020
MongoDB shell version: 2.6.10
connecting to: 127.0.0.1:27020/test
> show dbs
2015-05-27T16:35:46.071+0500 listDatabases failed:{
"ok" : 0,
"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",
"code" : 13
} at src/mongo/shell/mongo.js:47
> use admin
switched to db admin
> db.auth('name', 'password')
1
> show dbs
admin 0.031GB
local 0.031GB
Т.е. при подключении нет прав до авторизации.
Как вариант, можете попробовать обновится на 2.6, там не много изменений.