mac m1 芯片安装mongodb,配置管理员

m1 芯片安装mongodb, 用brew方法安装的

  • brew install mongodb-community@4.4

  • 启动mongodb命令进程--(按照个人理解,用这命令启动,会自动加载,/opt/homebrew/etc/mongod.conf文件)

brew services start mongodb-community@4.4
brew services stop mongodb-community@4.4
brew services restart mongodb-community@4.4
  • 实测:更改mongod.conf文件,即使里面有问题,重启是会成功的,命令提示成功,但会在连接的时候发现连接不上

我的mac启动路径----由此进入数据库命令终端
cd /opt/homebrew/opt/mongodb-community@4.4/bin
./mongo

直接输入mongo,启动不了
vim ~/.bash_profile

export PATH="$PATH:/opt/homebrew/opt/mongodb-community@4.4/bin"

source ~/.bash_profile

  • mongod.conf 配置文件

db.createUser({user:"hzcando",pwd:"xzsp_***",roles:[{ role: "readWrite", db: "xzsp" }]});

  • 修改增加需认证 ,编辑/opt/homebrew/etc/mongod.conf 添加2行配置:
   security:
   	authorization:enabled
  • tips:enabled需要认证,需要用户名和密码-----disabled 不需要用户名和密码

  • 实测:设置成disabled,即使用户用户名和密码登录,也是可以登录的

  • mac 重启mongodb brew services restart mongodb-community@4.4

db.getUsers(); // 查看所有的用户信息
db.getUser('username'); // 查看某个用户信息;
posted @ 2022-10-22 17:18  盘思动  阅读(287)  评论(0编辑  收藏  举报