mac 安装mongodb

使用brew install mongodb安装mongodb时提示:No available formula with the name “mongodb”。

看了一下网上介绍的brew安装mongodb的方法好像都是上面执行后提示错误的命令。

去官网查了一下,发现官网推荐的方法好像和网上之前介绍的不太一样。

官网步骤:

首先tap一个仓库
    brew tap mongodb/brew
1
安装社区版(商业版没研究~)
    brew install [email protected]
1
后面的@4.2省略应该也行,默认安装最新版本。(安装是最新4.2)

启动:$ brew services start mongodb-community

输入 sudo mkdir -p /data/db(6.0版本不用此命令)

输入 sudo mongod(6.0版本不用此命令)

输入 mongo((6.0版本为mongosh)

创建数据库 use house_reptile

添加用户名和权限

db.createUser({user: "root",pwd: "12345678",roles: [ { role: "userAdminAnyDatabase", db: "admin" },{ role: "dbAdminAnyDatabase",db: "admin" }, { role: "readWriteAnyDatabase", db: "admin" }]})

Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted

mongodb-27017.sock 删除此文件

https://segmentfault.com/a/1190000015603831

猜你喜欢

转载自blog.csdn.net/txl910514/article/details/104687367#comments_26477446
今日推荐