$ brew tap mongodb/brew
$ brew install mongodb-community
$ brew services start mongodb-community
$ mongo
报错:
MongoDB shell version v4.4.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
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:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
$ cat /usr/local/var/log/mongodb/mongo.log
{“t”:{“KaTeX parse error: Expected 'EOF', got '}' at position 38: …6:22.780+08:00"}̲,"s":"W", "c":…date”:“2020-10-17T13:46:22.815+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:23285, “ctx”:“main”,“msg”:“Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’”}
{“t”:{“KaTeX parse error: Expected 'EOF', got '}' at position 38: …6:22.834+08:00"}̲,"s":"W", "c":…date”:“2020-10-17T13:46:22.834+08:00”},“s”:“I”, “c”:“NETWORK”, “id”:4648602, “ctx”:“main”,“msg”:“Implicit TCP FastOpen in use.”}
{“t”:{“KaTeX parse error: Expected 'EOF', got '}' at position 38: …6:22.844+08:00"}̲,"s":"I", "c":…date”:“2020-10-17T13:46:22.844+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:23403, “ctx”:“initandlisten”,“msg”:“Build Info”,“attr”:{“buildInfo”:{“version”:“4.4.1”,“gitVersion”:“ad91a93a5a31e175f5cbf8c69561e788bbc55ce1”,“modules”:[],“allocator”:“system”,“environment”:{“distarch”:“x86_64”,“target_arch”:“x86_64”}}}}
{“t”:{“KaTeX parse error: Expected 'EOF', got '}' at position 38: …6:22.844+08:00"}̲,"s":"I", "c":…date”:“2020-10-17T13:46:22.844+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:21951, “ctx”:“initandlisten”,“msg”:“Options set by command line”,“attr”:{“options”:{“config”:"/usr/local/etc/mongod.conf",“net”:{“bindIp”:“127.0.0.1”},“storage”:{“dbPath”:"/usr/local/var/mongodb"},“systemLog”:{“destination”:“file”,“logAppend”:true,“path”:"/usr/local/var/log/mongodb/mongo.log"}}}}
{“t”:{“KaTeX parse error: Expected 'EOF', got '}' at position 38: …6:22.846+08:00"}̲,"s":"E", "c":…date”:“2020-10-17T13:46:22.846+08:00”},“s”:“F”, “c”:"-", “id”:23091, “ctx”:“initandlisten”,“msg”:“Fatal assertion”,“attr”:{“msgid”:40486,“file”:“src/mongo/transport/transport_layer_asio.cpp”,“line”:919}}
{“t”:{"$date":“2020-10-17T13:46:22.846+08:00”},“s”:“F”, “c”:"-", “id”:23092, “ctx”:“initandlisten”,“msg”:"\n\n***aborting after fassert() failure\n\n"}
$ sudo rm -rf /usr/local/Cellar/mongodb-community/4.4.1
# 安装
$ brew reinstall mongodb-community
重新运行即可:brew services start mongodb-community