1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# 只需要在PRIMARY机器(AI02) 执行, 用户信息会同步到其他机器
docker exec -it mongo_9690 mongo
# 在admin库添加admin和nolan两个用户
> use admin
> db.createUser({user: "admin", pwd: "PASSWORD", roles: [{role: "userAdminAnyDatabase", db: "admin"}]})
> db.auth('admin', 'PASSWORD')
> db.createUser({ user: "nolan", pwd: "PASSWORD", roles: [{ role: "dbOwner", db: "db_train" }, { role: "dbOwner", db: "db_recognition" }, { role: "dbOwner", db: "db_store" }] })
# 分别在其他库创建nolan用户
> use db_store
> db.createUser({ user: "nolan", pwd: "PASSWORD", roles: [ { role: "dbOwner", db: "db_store" }] })
> use db_recognition
> db.createUser({ user: "nolan", pwd: "PASSWORD", roles: [{ role: "dbOwner", db: "db_recognition" }] })
> use db_train
> db.createUser({ user: "nolan", pwd: "PASSWORD", roles: [{ role: "dbOwner", db: "db_train" }] })
|