use*_*291 1 opensuse mongodb keystonejs
我按照这种方法启动一个KeystoneJS项目。但是进入项目根目录并运行后,node keystone.js我收到错误消息:
------------------------------------------------
An error occurred applying updates, bailing on Keystone init.
Error details:
MongoError: not authorized on <KeystoneJS project name> to execute command { find: "app_updates", filter: { key: "0.0.1-admins" }, limit: 1, batchSize: 1, singleBatch: true }
Run Code Online (Sandbox Code Playgroud)
我研究了此错误,但无法解决。我正在使用OpenSUSE,并且正在使用nodejs8软件包。
当我通过运行在systemd上启动mongodb时:
$ sudo systemctl start mongodb.service
Run Code Online (Sandbox Code Playgroud)
...我收到上述错误。
但是当我通过运行启动mongodb时:
$ sudo mongod
Run Code Online (Sandbox Code Playgroud)
...我没有收到任何错误,keystonejs可以正常工作,我不确定为什么!
通过运行启动mongodb时,$ sudo mongod -f /etc/mongodb.conf出现上述错误。但是,当我通过运行启动mongodb时$ sudo mongod,我没有收到任何错误。因此,看起来问题原因在/etc/mongodb.conf文件内,如下所示:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
#dbPath: /data/db/
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# Where and how to log messages.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
logRotate: reopen
# What type of connections to allow.
net:
port: 27017
bindIp: 127.0.0.1
ipv6: true
http:
enabled: false
JSONPEnabled: false
RESTInterfaceEnabled: false
# How to manage mongod.
processManagement:
fork: true
# Security settings.
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
Run Code Online (Sandbox Code Playgroud)
小智 5
在您的配置中,您正在使用访问Mongo的授权
# Security settings.
security:
authorization: enabled
Run Code Online (Sandbox Code Playgroud)
首先,您需要创建用户-打开mongo控制台(mongo),无需配置即可启动mongod
mongod --port 27017 --dbpath /data/db1
Run Code Online (Sandbox Code Playgroud)
使用控制台连接到实例
mongo --port 27017
Run Code Online (Sandbox Code Playgroud)
在mongo控制台中输入下一步命令
use admin
db.createUser(
{
user: "superAdmin",
pwd: "admin123",
roles: [ { role: "root", db: "admin" } ]
})
Run Code Online (Sandbox Code Playgroud)
现在您可以通过配置将mongo用作服务使用
mongo --port 27017 -u "superAdmin" -p "admin123" --authenticationDatabase "admin"
Run Code Online (Sandbox Code Playgroud)
因此,您需要通过创建具有ReadWrite权限的新用户来授予对mongo的访问权限
use myAppDb #its name of your Database
db.createUser(
{
user: "myAppDbUser", #desired username
pwd: "myApp123", #desired password
roles: [ "readWrite"]
})
Run Code Online (Sandbox Code Playgroud)
并尝试使用此凭据连接mongo --port 27017 -u“ myAppDbUser” -p“ myApp123” --authenticationDatabase“ myAppDb”
并使用此用户进行梯形校正配置以连接到mongo,例如
mongodb://myAppDbUser:myApp123@localhost:27017/myAppDb
Run Code Online (Sandbox Code Playgroud)
(通过https://medium.com/@raj_adroit/mongodb-enable-authentication-enable-access-control-e8a75a26d332)
| 归档时间: |
|
| 查看次数: |
6408 次 |
| 最近记录: |