Mongodb keystoneJs“;未授权查询keystone.app“U更新”;
我试图在服务器上运行keystone JS项目,但它刚刚停止。我在mongodb上创建了一个用户user:pwd,并将配置添加到keystone的Mongodb keystoneJs“;未授权查询keystone.app“U更新”;,mongodb,keystone,Mongodb,Keystone,我试图在服务器上运行keystone JS项目,但它刚刚停止。我在mongodb上创建了一个用户user:pwd,并将配置添加到keystone的.env文件中,就像doc说的: MONGO_-URI=mongodb://keystone:keystone@localhost:27017/keystone 它将成功与mongo cli联系起来 > use keystone switched to db keystone > db.auth({user:"keystone",pwd:
.env
文件中,就像doc说的:
MONGO_-URI=mongodb://keystone:keystone@localhost:27017/keystone
它将成功与mongo cli联系起来
> use keystone
switched to db keystone
> db.auth({user:"keystone",pwd:"keystone"})
1
----------------------------------------------
> show dbs
admin 0.000GB
keystone 0.000GB
local 0.000GB
log4net 0.143GB
但是keystone总是显示下面的错误
------------------------------------------------
An error occurred applying updates, bailing on Keystone init.
Error details:
MongoError: not authorized for query on keystone.app_updates
我在本地使用默认的mongodb成功运行了一个keystone项目。
如何使用auth将密钥石配置到mongodb?有人能给我指路吗
谢谢您的keystone应用程序可能没有拾取.env文件 另一种方法是在初始化keystone之前传递URI以设置keystone mongo选项
keystone.set(“mongo”mongodb://keystone:keystone@localhost:27017/keystone“
执行此操作时,我使用命令行arg设置密码,因此在运行服务器时,它看起来像:
节点keystone.js密码
当我设置mongo uri时,它看起来像:
password = process.argv[2]
keystone.set("mongo","mongodb://keystone:"+password"+@localhost:27017/keystone")
这样我就不会在文件中有明文密码了