mongodb权限认证

Error: not authorized on database to execute command { listCollections: 1.0, filter: { type: "collection" }, nameOnly: false, authorizedCollections: false.
docker 安装mongodb:
docker pull mongo:latest

docker ps 查看CONTAINER ID
进入容器:

docker exec -it 容器id mongo admin

创建用户:

db.createUser({ user: ‘admin‘, pwd: ‘123‘, roles: [ { role: "userAdminAnyDatabase", db: "demo" } ] });
db.auth(‘admin‘,‘123‘)

新创建数据库:

db.grantRolesToUser(‘admin‘,[{ role: "dbAdmin", db: "demo" }])

mongodb权限认证

上一篇:golang gdb调试


下一篇:Android开发 Fragment启动Activity在使用onActivityResult的一些问题