先测试一下mongoDB
是否安装成功:
which mongod
显示为:
/usr/local/bin/mongod
说明mongodb已经安装成功
在终端输入:
mongo
然后出现如下错误:
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
2018-07-17T15:17:05.983+0800 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed
解决:
brew services start mongodb
证明已经成功,那么你在终端继续输入
mongo
启动服务就ok
啦!