mongodb 安装

macOS 12.6.7 使用 .tgz,安装版本4.4

参考:https://www.mongodb.com/docs/v4.4/tutorial/install-mongodb-on-os-x-tarball/

.tgz方式需要自己创建mongod.conf,这里放到了/etc

参考:https://www.mongodb.com/docs/v4.4/reference/configuration-options/

https://www.mongodb.com/docs/v4.4/administration/configuration/#std-label-base-config

# 数据库文件存储路径
dbpath=/Users/g/data/db

# 监听的 IP 地址,可修改为具体的 IP 地址或 0.0.0.0(监听所有地址)
bind_ip=127.0.0.1

# 监听的端口号
port=27017

# 日志文件路径
logpath=/Users/g/data/log/mongodb/mongod.log
logappend=true

# 启用认证
auth=true

运行mongoDB

mongo --config /etc/mongod.conf

开启认证

https://www.mongodb.com/docs/v4.4/tutorial/enable-authentication/

连接数据库

认证权限

 https://www.mongodb.com/docs/v4.4/reference/method/db.auth/#mongodb-method-db.auth
posted @ 2023-10-16 17:53  Merrys  阅读(21)  评论(0编辑  收藏  举报