Reputation: 73
I am unable to connect Atlas MongoDB while using --host
option, But i'm able to connect while using --uri
option where did i made a mistake?
For example:
--uri option It's working fine
mongodump --uri="mongodb+srv://<username>:<password>@<hostname>/<dbname>" --gzip --out=/dir1/dir2
--host option getting error like
Failed: error connecting to db server: no reachable servers
mongodump --host <hostname>:<port> --username <username> --password <password> --authenticationDatabase <dbusername> --gzip --db <dbname> --out /dir/dir2
Upvotes: 0
Views: 416
Reputation: 59563
Based on comment you can try this:
mongodump --uri="mongodb+srv://<username>:<password>@<hostname>/" --db=<dbname> --gzip --out=/home/dir1/
You may need to specify the authentication database:
mongodump --uri="mongodb+srv://<username>:<password>@<hostname>/?authSource=admin" --db=<dbname> --gzip --out=/home/dir1/
See Authentication failure while trying to save to mongodb
Upvotes: 0
Reputation: 5414
As you can see here, if you connect using --uri
you use a MongoDB URI resource (starting with mongodb://
)
mongodump --uri="mongodb://mongodb0.example.com:27017" [additional options]
But if you use --host
you don't, as this is not a MongoDB URI:
mongodump --host="mongodb0.example.com:27017" [additional options]
Source: mongodump docs
Upvotes: 0