[英]Connecting using MongoDB Compass to docker mongo image
I'm trying to see the contents of a collection using MongoDB Compass.我正在尝试使用 MongoDB Compass 查看集合的内容。 I have username/password authentication set up.
我设置了用户名/密码身份验证。 I can log in successfully but can't see any documents in the collection.
我可以成功登录,但在集合中看不到任何文档。 Instead, I see the error:
相反,我看到了错误:
An error occurred while loading navigation: command hostInfo requires authentication.加载导航时出错:命令 hostInfo 需要身份验证。
Docker Compose file Docker 编写文件
version: '3.7'
services:
mongo:
image: mongo
restart: always
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: pass
volumes:
- ./mongo/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
- ./mongo:/data/db
mongo-express:
image: mongo-express
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_BASICAUTH_USERNAME: rmurad93
ME_CONFIG_BASICAUTH_PASSWORD: Qwert111
ME_CONFIG_MONGODB_PORT : 27017
ME_CONFIG_MONGODB_ADMINUSERNAME: admin
ME_CONFIG_MONGODB_ADMINPASSWORD: pass
init-mongo.js file初始化 mongo.js 文件
use admin
db.createUser({
user: "rmurad93",
pwd: "password",
roles: [ { role: "root", db: "admin" } ]
})
Line in terminal mongo compass终端 mongo 指南针中的线路
mongodb://localhost:27017/rmurad93:password
to connect to MongoCompass you should follow this pattern mongodb://USERNAME:PASSWORD@localhost:27017/DB_NAME要连接到 MongoCompass,您应该遵循此模式 mongodb://USERNAME:PASSWORD@localhost:27017/DB_NAME
If you still can't connecting, try using (Fill in connection fields individually) option shown above instead of (Paste connection string)如果仍然无法连接,请尝试使用上面显示的(分别填写连接字段)选项而不是(粘贴连接字符串)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.