mango 部署
docker run --net testenv --ip 10.10.1.27 --name mongo --privileged=true -p 27017:27017 -v /root/mongo/db:/data/db -v /root/mongo/log:/data/log -itd --restart=always mongo --auth
进入控制台创建用户
// version < 5
docker exec -it mongo sh admin
// version >= 5
docker exec -it mongo mongosh admin
进入控制台使用错误版本的命令可能会导致如下错误
docker exec -it mongo mongo admin
OCI runtime exec failed: exec failed: unable to start container process: exec: "mongo":
executable file not found in $PATH: unknown
创建用户
db.createUser({ user:'admin',pwd:'123456',roles:[ { role:'userAdminAnyDatabase', db: 'admin'},"readWriteAnyDatabase"]});