Reputation: 1
I trying to run a keystoneJs project on server, but it just down.I created a user on mongodb with user:pwd, And added the config into the .env
file of keystone like doc said:
MONGO_URI=mongodb://keystone:keystone@localhost:27017/keystone
It connected success with the 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
But the keystone always show the err below.
------------------------------------------------
An error occurred applying updates, bailing on Keystone init.
Error details:
MongoError: not authorized for query on keystone.app_updates
I have run a keystone project success at local with a default mongodb. How do I config the keystone to a mongodb with auth? Can anybody show me the way?
Thanks
Upvotes: 0
Views: 566
Reputation: 63
It is possible that your keystone app is not picking up the .env file.
An alternative is to pass the URI to set the keystone mongo option before you initialise keystone.
keystone.set("mongo","mongodb://keystone:keystone@localhost:27017/keystone")
When I do this I set the password with a commandline arg so when i run the server it looks like:
node keystone.js password
And when I set the mongo uri it looks like:
password = process.argv[2]
keystone.set("mongo","mongodb://keystone:"+password"+@localhost:27017/keystone")
Just so I don't have a password sitting in plaintext in a file.
Upvotes: 0