Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MongoDB error report & an example of solving quot;not authorized on root to execute command" problem

2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Root users report an error when modifying the MongoDB authentication mechanism:

> use admin

> db.auth ('root','123456')

> var schema=db.system.version.findOne ({"_ id": "authSchema"})

Y > schema.currentVersion = 3

three

> db.system.version.save (schema)

WriteResult ({

"writeError": {

"code": 13

"errmsg": "not authorized on root to execute command {update:\" system.version\ ", updates: [{Q: {_ id:\" authSchema\ "}, u: {_ id:\" authSchema\ ", currentVersion: 3}, multi: false, upsert: true}], ordered: true}"

}

})

This error is due to the fact that the admin user is not authorized to execute commands on the system.version table. The workaround is as follows:

> db.grantRolesToUser ("root", [{role: "_ system", db: "admin"}])

The command was executed again successfully:

> db.system.version.findOne ({"_ id": "authSchema"})

{"_ id": "authSchema", "currentVersion": 3}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report