首页 > 数据库 > > mac上mongodb安装与启动问题

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"到终端,按回车开始安装mongodb,静待安装完成。
出现
[thread1]Failed to connect to 127.0.0.1:27017,in (checking socket for error after poll),reason:Connection refused
[thread1]Error:could't connect to server 127.0.0.1:27017,connection attempt failed:
connect@ src/mongo/shell.js:237:13
@(connect)1:6
exception:connect failed

1、先检查mongodb是否运行
终端中输入ps -ef|grep mongo
2、检查which是否安装,安装目录在哪里
终端中输入
which mongod
3、查看mongo的配置
homebrew安装mongodb应该是在/usr/local/etc目录中。

4、打开mongod.conf文件

下列代码
mongod --config=/usr/local/etc/mongod.conf在浏览器中访问127.0.0.1:27017 显示正常

systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /usr/local/var/mongodb
net:
bindIp: 127.0.0.1
fork: true
好了。
花了50元的红包得到zz帮助,值了。要不然我要纠结好几天半个月甚至一年。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31537575/viewspace-3145753/ ,如需转载,请注明出处,否则将追究法律责任。