在遵循settings.py中使用的数据库连接详细信息时收到错误

时间:2014-12-17 12:01:37

标签: mongodb eve

在执行前夕文档示例时,我得到了 跟随数据库的错误。有人知道帮助我。 技术用于eve框架和mongodb。 基本错误,所以任何人都可以解决它。

settings.py
MONGO_HOST = 'localhost'
MONGO_PORT = 5000
MONGO_USERNAME = 'user'
MONGO_PASSWORD = 'user'
MONGO_DBNAME = 'apitest'

DOMAIN = {'people': {}}

error

(tornado_weber_env)weber@weber-desktop:~/tornado_weber_env/testing$ python run.py
Traceback (most recent call last):
File "run.py", line 3, in 
app = Eve()
File "/home/weber/tornado_weber_env/local/lib/python2.7/site-packages/eve/flaskapp.py",        
line 136, in init
self.data = data(self)
File "/home/weber/tornado_weber_env/local/lib/python2.7/site-packages/eve/io/base.py",     
line 100, in init
self.init_app(self.app)
File "/home/weber/tornado_weber_env/local/lib/python2.7/site-    
packages/eve/io/mongo/mongo.py", line 73, in init_app
raise ConnectionException(e)
eve.io.base.ConnectionException: Error initializing the driver. Make sure the database    
server is running. Driver exception: OperationFailure(u"command SON([('authenticate', 1), 
('user', u'user'), ('nonce', u'6d4bfd537685c4b4'), ('key', 
u'f846d47fa6ee80a42807cc2e7bf8b8cf')]) failed: auth failed",)

(tornado_weber_env)weber@weber-desktop:~/tornado_weber_env/testing$ python run.py
Traceback (most recent call last):
File "run.py", line 3, in 
app = Eve()

File "/home/weber/tornado_weber_env/local/lib/python2.7/site-packages/eve/flaskapp.py",   
line 136, in init

self.data = data(self)
File "/home/weber/tornado_weber_env/local/lib/python2.7/site-packages/eve/io/base.py",
line 100, in init
self.init_app(self.app)
File "/home/weber/tornado_weber_env/local/lib/python2.7/site-   
packages/eve/io/mongo/mongo.py", line 73, in init_app

raise ConnectionException(e)
eve.io.base.ConnectionException: Error initializing the driver. Make sure the database
server is running. Driver exception: Connection Failure('[Err no 111] Connection refused',)

2 个答案:

答案 0 :(得分:0)

首先验证您的计算机上是否正在运行mongodb,请参阅the Mongo documentation。在setting.py中执行此操作后,将mongod信息更改为您的设置:

MONGO_HOST = 'localhost' # If your mongo server is locally running
MONGO_PORT = <port_to_your_mongo_server>
MONGO_USERNAME = ''
MONGO_PASSWORD = ''
MONGO_DBNAME = 'apitest'

答案 1 :(得分:0)

碰到了同样的问题。

用户名和密码必须设为空&#39;&#39;

默认情况下,

mongodb,以无身份验证开始。

因此,在 settings.py 设置

MONGO_USERNAME =&#39;&#39;

MONGO_PASSWORD =&#39;&#39;