OS X 环境下用 brew 安装 mongodb 之后
按照官方文档上的教程 import 一个 json 文件
输入:
mongoimport --db test --collection restaurants --drop --file primer-dataset.json
过程中 出现报错
Failed: error connnecting to db server: no reachable servers
求解决方案
已经尝试过的解决方案:
1.mongoimport --host=127.0.0.1 --port=27017 --db test --collection restaurants --drop --file primer-dataset.json
2.brew update && brew upgrade
补充:
1.启动mongodb之后导入文件,报错:
Failed: error processing document #9870: unexpected EOF
It looks like the data file is damaged, open it with vi and take a look at the data file to be imported.
Are you sure your mongodb is started?
What version of MongoDB is it? This problem will not occur after 3.0.7. Also, is --replSet enabled but not in node? Finally, I checked it for you. Someone had a similar problem and solved it through mongorestore dump --host=127.0.0.1.