Reputation: 706
I am trying to import some data from a csv file on my computer to a cluster on Atlas. I cannot get it to work or find an answer here. I have imported the same file to my local DB on my computer, I just can't get it to work with Atlas. I think that the problem is my connection string, but I don't know what I am doing wrong.
Mongoimport command:
mongoimport --uri "mongodb://<username>:<password>@<clustername>-<string(private?)>.mongodb.net/<database>?authSource=admin&ssl=true" --collection <cname> --drop --type csv --file <path/to/file.csv --headerline
Connection string from MongoDB Atlas:
mongo "mongodb+srv://<clustername>-<string(private?)>.mongodb.net/test" --username <username>
Error:
error connecting to host: could not connect to server: server selection error: server
selection timeout, current topology: { Type: Single, Servers: [{ Addr: <clustername>-
<string(private?)>.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error:
connection() : dial tcp: lookup <clustername>-<string(private?)>.mongodb.net on 127.0.0.53:53: no such
host }, ] }
I have tried everything that I can think of and this seems to be the closest that I can get. It seems to me like I have the connection string wrong, but I don't know how to fix it. I am new to working with databases and MongoDB in particular. Any help is much appreciated.
Notes: I am running this in the terminal and not in the mongo shell. The import worked on my local machine with this same file.
Upvotes: 1
Views: 2140
Reputation: 66
Try removing the ssl=true parameter from the uri in mongoimport, since you are passing client and ca certs in the command.
And another suggestion, in the uri use all the hostnames of the cluster. If you have cluster with multiple nodes which is usually the case.
or Alternatively:
Find command line tools in the altas page. it as template command for mongoimport to the cluster.
Hope this helps.
Click in the expand button and then click on the command line tools
Upvotes: 1