mac mongodb鏈接connect fail解決

 

MongoDB shell version v3.6.0
connecting to: mongodb://127.0.0.1:27017
2017-12-27T09:54:34.775+0800 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-27T09:54:34.778+0800 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:237:13
@(connect):1:6
exception: connect failedmongodb

嘗試各類方法都不行shell

當mongodb service 沒有運行的時候會發生這樣的錯誤數據庫

嘗試了新建一個/data/db 目錄,也不奏效。socket

後來經過搜索,尋找到來解決方法,運行命令spa

brew services start mongodb

再去調用數據庫命令rest

mongo

就能夠完美解決問題了code

最終mac下顯示成功的提示server

複製代碼
MongoDB shell version v3.6.0
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.0
Server has startup warnings: 
2017-12-27T09:54:58.316+0800 I CONTROL  [initandlisten] 
2017-12-27T09:54:58.316+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-12-27T09:54:58.316+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-12-27T09:54:58.316+0800 I CONTROL  [initandlisten] 
> 
複製代碼
相關文章
相關標籤/搜索