我为我的Heroku应用程序配置了一个MongoDB,我可以很好地连接到数据库(使用第三方MongoDB UI工具)。我创建了一个新用户并收到了以下消息:
Successfully added user: {
"user" : "username",
"roles" : [
{
"role" : "dbAdmin",
"db" : "heroku_340171"
}
]
}
然而,在运行我的Django应用程序时,我收到以下错误:
File "g:\Git\ChatterbotTest\chatterbottest\urls.py", line 3, in <module>
from views import FbView
File "g:\Git\ChatterbotTest\chatterbottest\views.py", line 33, in <module>
database_uri="mongodb://username:password@ds23123.mlab.com:13938/heroku_340171"
File "g:\Python\lib\site-packages\chatterbot\chatterbot.py", line 37, in __init__
self.storage = utils.initialize_class(storage_adapter, **kwargs)
File "g:\Python\lib\site-packages\chatterbot\utils.py", line 33, in initialize_class
return Class(**kwargs)
File "g:\Python\lib\site-packages\chatterbot\storage\mongodb.py", line 102, in __init__
self.statements.create_index('text', unique=True)
File "g:\Python\lib\site-packages\pymongo\collection.py", line 1529, in create_index
self.__create_index(keys, kwargs)
File "g:\Python\lib\site-packages\pymongo\collection.py", line 1430, in __create_index
parse_write_concern_error=True)
File "g:\Python\lib\site-packages\pymongo\collection.py", line 232, in _command
collation=collation)
File "g:\Python\lib\site-packages\pymongo\pool.py", line 419, in command
collation=collation)
File "g:\Python\lib\site-packages\pymongo\network.py", line 116, in command
parse_write_concern_error=parse_write_concern_error)
File "g:\Python\lib\site-packages\pymongo\helpers.py", line 210, in _check_command_response
raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: not authorized on chatterbot-database to execute command { createIndexes: "statements", indexes: [ { unique: true, name: "text_1", key: { text: 1 } } ] }
dbAdmin
应具有运行createIndexes
的权限。出了什么问题?