尝试运行mongorestore并且无法连接?

时间:2019-04-14 16:06:09

标签: mongodb

使用MongoAtlas并尝试运行mongorestore时,出现以下错误。

Failed: error connecting to db server: no reachable servers

我正在使用Atlas建议的命令。

mongorestore --host BStaging-shard-0/bstaging-shard-00-00-lq11i.mongodb.net:27017,bstaging-shard-00-01-lq11i.mongodb.net:27017,bstaging-shard-00-02-lq11i.mongodb.net:27017 --ssl --username heroku --password "VN" --authenticationDatabase admin 
2019-04-14T11:02:31.336-0500    

Failed: error connecting to db server: no reachable servers

1 个答案:

答案 0 :(得分:0)

已修复:

  1. 更新的MongoDB社区Shell
  2. 将bash_profile更改为指向新的shell
  3. 将bash_profile更改为指向新的mongo db community4.0

    (/ usr/local/opt/mongodb-community@4.0/bin:/ usr / local / opt / mongodb-community-shell / bin:$ PATH)

  4. 源bash_profile

  5. 重新连接到mongo

    mongo“ mongodb://staging-shard-00-00-dgdr.mongodb.net:27017,staging-shard-00-01-dgdr.mongodb.net:27017,staging-shard-00-02-dgdr .mongodb.net:27017 / test?replicaSet = Staging-shard-0“ --ssl --authenticationDatabase admin-用户名me-密码pwd

  6. 还原

    mongorestore --host分段--0 /分段-00-00-dgdr.mongodb.net:27017,分段-00-01-dgdr.mongodb.net:27017,分段-00 -02-dgdr.mongodb.net:27017 --ssl-用户名我-密码pwd --authentication数据库管理员