mongodb - 错误 : not authorized on db to execute command

标签 mongodb authentication mongorestore bigdata

我正在尝试使用 mongo 3.0.7 中的 mongorestore 恢复一个大文件。 prod079 文件夹下的所有文件都已成功恢复,除了一个名为 system.users 的文件。用于恢复的命令是

 mongorestore -u testdba -p xxxxxx -d prod079 /data/backup --batchSize=1

上面的命令从同一个文件夹中恢复了 400GB 的数据,但似乎只用这个文件就失败了。

我收到这样的错误:

error: not authorized on prod079 to execute command { insert: "system.users", documents: [ { _id: ObjectId('531e5251864fb4e84b'), pwd: "xxxxxxxx", roles: [ "dbAdmin", "readWrite", "userAdmin" ], user: "ab" } ], writeConcern: { getLastError: 1, w: 1 }, ordered: false }

2015-12-10T13:20:49.196-0500 error: not authorized on prod079 to execute command { insert: "system.users", documents: [ { _id: ObjectId('531e5251864fb4e84c'), user: "abuser", pwd: "xxxxxxxx", roles: [ "read" ] } ], writeConcern: { getLastError: 1, w: 1 }, ordered: false }

2015-12-10T13:20:49.196-0500 error: not authorized on prod079 to execute command { insert: "system.users", documents: [ { _id: ObjectId('5452840f169afa3a2'), user: "asmeta", pwd: "xxxxxxxx", roles: [ "read" ] } ], writeConcern: { getLastError: 1, w: 1 }, ordered: false }



所以基本上我会遇到很多这样的错误。我尝试在 stackoverflow 和 google 上寻找类似的错误,但我能找到的只是包含 -d 或包含 localhost。然后我发现一个帖子说我没有为 testdba 用户授予 userAdmin/userAdminAnyDatabase 权限。这次我尝试以具有 userAdmin/userAdminAnyDatabase 权限的管理员用户身份运行。我使用的命令是:
mongorestore -u admin -p xxxxx -d prod079 /data/backup --batchSize=1 

这次我遇到了不同类型的错误。它说 :

2015-12-10T13:17:59.940-0500 Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed.



现在我真的很困惑发生了什么以及为什么我单独面对这个文件的问题。此外,当我尝试以管理员身份恢复时,我无法理解为什么我会收到如此不同的错误。

任何建议/帮助将不胜感激。

最佳答案

我尝试了上面列出的所有方法,但都没有奏效。

我将“恢复”角色赋予管理员用户,并且它起作用了。

documentation 中查看有关“恢复”的更多信息。

关于mongodb - 错误 : not authorized on db to execute command,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34211219/

相关文章:

node.js - Mongoose 关注/关注者

javascript - MongoError $regex 必须是一个字符串

python - 为什么 PyMongo 脚本至少需要 500 毫秒才能执行?

security - 如何根据URL中的单页ID限制权限?

asp.net - Facebook 身份验证与 ASP.NET Core 2.1 : OAuth "Facebook Platform" "invalid_code" "This authorization code has been used."

mongodb - 升级mongoDB数据库首选Mongodump VS Mongoexport哪一个?

mongodb - 如何从 atlas 备份文件中恢复 mongo?

c# - 使用 C# 驱动程序从 SQL 表读取数据并导出到 MongoDB 的通用方法

ruby-on-rails - Rails 中的多个 token 和多个提供者身份验证

mongodb - 转储远程数据库 : Failed: error connecting to db server: no reachable servers