用户名:root
密码:123456
version: '3.1'
services:
mongo:
image: mongo:7
container_name: mongo
restart: always
ports:
- 27017:27017
volumes:
- /opt/data/mongo:/data/db
environment:
TZ: Asia/Shanghai
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: 123456
mongo-express:
image: mongo-express
container_name: mongo-express
restart: always
ports:
- 8081:8081
environment:
TZ: Asia/Shanghai
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: 123456
ME_CONFIG_MONGODB_URL: mongodb://root:123456@mongo:27017/
web管理界面:
创建库和普通用户,demo库不存在会自动创建
use demo
db.createUser({
user: "demo",
pwd: "tangwan",
roles: ["readWrite"]
})