It looks like the MongoDB user/pw combo you configured in your settings.py
has not been set at the db level. From the mongo shell type use <dbname>
, then db.system.users.find()
to get a list of authorized users for <dbname>
. It is probably empty; add the user as needed (see the MongoDB docs).
ConnectionException connecting a Eve REST API to a MongoDB instance
题
I just installed the 'eve demo' I can't get it to start working.
The error is:
eve.io.base.ConnectionException: Error initializing the driver. Make sure the database serveris running. Driver exception: OperationFailure(u"command SON([('authenticate', 1), ('user', u'user'), ('nonce', u'cec66353cb35b6f5'), ('key', u'14817e596653376514b76248055e1d4f')]) failed: auth fails",)
I have mongoDB running, and I have installed Eve and Python2.7.
I create the run.py and the settings.py required.
What is not working ? am I missing something ?
解决方案
其他提示
get your mongodb's dbname,username and password from setting.py,eg:
MONGO_USERNAME = 'username' MONGO_PASSWORD = 'password' MONGO_DBNAME = 'apitest'
login in mongod server with mongo,and make sure your username in dbname's system.user collection.you can query authenticated users in that database with the following operation:
use apitest db.system.users.find()
if username doesn't exist in system.users,then you can use db.addUser command to add a user to system.users collection.eg:
use apitest db.addUser{'username','password'}