连接主机错误:无法连接服务器:服务器选择错误:服务器选择超时当前拓扑:类型:单服务器 [英] error connecting to host: could not connect to server: server selection error: server selection timeout current topology: Type: Single Servers
问题描述
不幸的是,我需要将CSV文件导入mongoDB,但出现以下错误:
I need to import a CSV file to mongoDB unfortunately i'm having below error:
error connecting to host: could not connect to server: server selection error: server selection timeout
current topology: Type: Single
Servers:
Addr: eaderline:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : dial tcp: lookup eaderline: no such host
我的导入字符串如下:
mongoimport --host Test-shard-0/test-shard-00-00-gceee.mongodb.net:27017,test-shard-00-01-gceee.mongodb.net:27017,test-shard-00-02-gceee.mongodb.net:27017 --ssl --username <username> --password <password> --authenticationDatabase admin --db EngineeringProject --collection FirstName --type csv -file "C:\Users\Ja\Desktop\INFA\ProjektInzynierski\DaneDBzMC\imiona.csv" -headerline
有关此错误的有趣之处在于,我能够在2周前通过类似字符串将数据导入mongodb,该字符串如下所示,而今天这是不可能的,为什么?
The funny part about this error is that, i was able to import data to mongodb a 2 weeks ago by similar string which looks like this one below, and today it's imposible, why?
mongoimport --host Test-shard-0/test-shard-00-00-gceee.mongodb.net:27017,test-shard-00-01-gceee.mongodb.net:27017,test-shard-00-02-gceee.mongodb.net:27017 --ssl --username <username> --password <password> --authenticationDatabase admin --db Test2 --collection COL_First --type csv -file "C:\Users\Ja\Desktop\Przykladowy\Mapy\liczba.csv" -headerline
有人看到任何错误吗?
我检查了机器上的端口27017是否空闲,也许集群端正在发生某些事情? 有没有一种方法可以启动空导入,仅用于检查连接?
I have checked the port 27017 on my machine is free, maybe there is something going on on the cluster side? Is there a way to launch an empty import, just for checking the connection?
推荐答案
使用URI命令在Windows命令行中对我有用
use URI command It works for me in windows command line
mongoimport --uri "mongodb://**user:passwd**@***host:port***/database?ssl=true&replicaSet=**replicasetneme**"
-c **collection** --file **csvFile** --fields **fields with comma separated**
这篇关于连接主机错误:无法连接服务器:服务器选择错误:服务器选择超时当前拓扑:类型:单服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!