Pymongo在尝试访问远程服务器时给出数据库断言失败

问题描述:

我收到以下错误:


db断言失败,断言:'未经授权的db:db1锁类型:-1客户端: ',assertionCode:10057

db assertion failure, assertion: 'unauthorized db:db1 lock type:-1 client:', assertionCode: 10057

我可以通过在我的服务器的shell上运行python来访问MongoDB数据库。但是当我尝试访问我的网站时,我会收到这个未经授权的错误。

I am able to access the MongoDB database by running python on the shell of my server. But when I try to access my site i get this unauthorised errors.

任何修复此错误?

这意味着您的数据库正在使用身份验证。在这样的设置中,您必须先验证有效的用户,然后才能执行任何操作(查询,命令,更新等)。您可以使用mongo shell中的 db.auth(username,password)帮助器(),使用Python可以使用 authenticate(username,password) / code>数据库的对象(

This means that your database is using authentication. In such a setup, you must authenticate a valid user before you can perform any operations (queries, commands, updates, etc). You can do so with the db.auth(username, password) helper in the mongo shell (described in the MongoDB docs), and with Python, you can use the authenticate(username, password) method of the Database object (described in the PyMongo docs)