I know this is a basic security measure, but I can't make it works with my mongodb installation.
(我知道这是一项基本的安全措施,但是我无法使其与mongodb安装一起使用。)
Each time I run the command : (每次我运行命令:)
mongorestore dump_folder -u "username" -p "password"
It returns:
(它返回:)
error reading database: not authorized on DATABASE_NAME to execute command { listCollections: 1, cursor: { batchSize: 0 } }
My question is : What is the permission that I need to enable and how ?
(我的问题是:我需要启用什么权限以及如何启用?)
For the time being, I just turn off the Mongo's security in /etc/mongod.conf
and start it back after I restore/dump my databases.
(暂时,我只是在/etc/mongod.conf
关闭Mongo的安全性, /etc/mongod.conf
在还原/转储数据库后重新启动它。)
Additional Note: This is how I prepared my databases and its user
(附加说明:这是我准备数据库及其用户的方式)
- I log in with my admin account, create a database, named DATABASE001
(我使用管理员帐户登录,创建一个名为DATABASE001的数据库)
And create a user:
(并创建一个用户:)
use DATABASE001 db.createUser({ user: "USER001", pwd: "mypassword", roles:[ { role: "readWrite", db: "DATABASE001" },"dbAdmin" ] })
For roles, I add readWrite
to DATABASE001 and also dbAdmin
I want this user (USER001) be able to backup or restore his database (DATABASE001).
(对于角色,我将readWrite
添加到DATABASE001,还将dbAdmin
添加到我希望该用户(USER001)能够备份或还原其数据库(DATABASE001)。)
I tested it by login with this command.
(我通过使用此命令登录进行了测试。)
It successfully logged in (它成功登录)
mongo localhost -u USER001 -p mypassword --authenticationDatabase DATABASE001
I want to dump this database content with:
(我想通过以下方式转储该数据库内容:)
mongodump -u USER001 -p mypassword --authenticationDatabase DATABASE001
it throws me an error: Failed: error getting database names: not authorized on admin to execute command { listDatabases: 1 }
(它引发了一个错误: Failed: error getting database names: not authorized on admin to execute command { listDatabases: 1 }
)
What is this listDatabases
?
(这个listDatabases
是什么?)
how can I add it to my roles? (如何将其添加到我的角色中?)
ask by DennyHiu translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…