docker pull mongo:latest
docker run -itd --name mongo-test -p 27017:27017 mongo --auth
auth:需要密码才能访问容器服务。
docker exec -it mongo-test mongo admin db.createUser({ user:'admin',pwd:'123123',roles:[ { role:'userAdminAnyDatabase', db: 'admin'},"readWriteAnyDatabase"]}); db.auth('admin', '123123')
navicat premium