error connecting to host: could not connect to server: server selection error: server selection timeout current topology: Type: Single Servers
error connecting to host: could not connect to server: server selection error: server selection timeout current topology: Type: Single Servers
我需要将 CSV 文件导入 mongoDB 不幸的是我遇到了以下错误:
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 a,如下所示,但今天却不可能,为什么?
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 是空闲的,可能是集群端发生了什么?
有没有办法启动一个空的导入,只是为了检查连接?
我终于能够通过 mongodb GUI 客户端 Compass 导入我的 CSV 文件。
与此同时,我遇到了另一个问题。 Compass 连接集群显示了 DB,但没有显示 collections。事实证明,我的用户扮演了一个坏角色。我删除了用户并再次添加它,它起作用了,我也可以看到 collections。
之后我就可以导入我的 CSV 文件了。
使用 URI 命令 它在 windows 命令行中对我有效
mongoimport --uri "mongodb://**user:passwd**@***host:port***/database?ssl=true&replicaSet=**replicasetneme**"
-c **collection** --file **csvFile** --fields **fields with comma separated**
1.First 确保数据库端口 27017 未被其他本地服务器实例使用
2.If 使用云,然后登录到控制台并单击 Cluster Name
然后 Command Line Tools
复制 mongo 导入命令,它看起来像
mongoimport --host DemoCluster-shard-0/democluster-shard-00-00-5zjhn.mongodb.net:27017,democluster-shard-00-01-5zjhn.mongodb.net:27017,democluster-shard-00-02-5zjhn.mongodb.net:27017 --ssl --username <USERNAME>--password <PASSWORD> --authenticationDatabase admin --db <DATABASE> --collection <COLLECTION> --type <FILETYPE> --file <FILENAME>
注意:如果文件包含 json 数组
,则将 TYPE 作为 --jsonArray
传递
每次遇到此类错误时:
error connecting to host: could not connect to server...
因为MongoDB没有启动。
尝试手动启动它。
作为 windows 用户:
我需要将 CSV 文件导入 mongoDB 不幸的是我遇到了以下错误:
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 a,如下所示,但今天却不可能,为什么?
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 是空闲的,可能是集群端发生了什么? 有没有办法启动一个空的导入,只是为了检查连接?
我终于能够通过 mongodb GUI 客户端 Compass 导入我的 CSV 文件。
与此同时,我遇到了另一个问题。 Compass 连接集群显示了 DB,但没有显示 collections。事实证明,我的用户扮演了一个坏角色。我删除了用户并再次添加它,它起作用了,我也可以看到 collections。
之后我就可以导入我的 CSV 文件了。
使用 URI 命令 它在 windows 命令行中对我有效
mongoimport --uri "mongodb://**user:passwd**@***host:port***/database?ssl=true&replicaSet=**replicasetneme**"
-c **collection** --file **csvFile** --fields **fields with comma separated**
1.First 确保数据库端口 27017 未被其他本地服务器实例使用
2.If 使用云,然后登录到控制台并单击 Cluster Name
然后 Command Line Tools
复制 mongo 导入命令,它看起来像
mongoimport --host DemoCluster-shard-0/democluster-shard-00-00-5zjhn.mongodb.net:27017,democluster-shard-00-01-5zjhn.mongodb.net:27017,democluster-shard-00-02-5zjhn.mongodb.net:27017 --ssl --username <USERNAME>--password <PASSWORD> --authenticationDatabase admin --db <DATABASE> --collection <COLLECTION> --type <FILETYPE> --file <FILENAME>
注意:如果文件包含 json 数组
,则将 TYPE 作为--jsonArray
传递
每次遇到此类错误时:
error connecting to host: could not connect to server...
因为MongoDB没有启动。
尝试手动启动它。
作为 windows 用户: