Connecting atlas cluster from shell

Hi all.
i am getting this error while connecting atlas cluster from windows shell.

C:\Program Files\MongoDB\Server\4.0\bin>mongo “mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shar
d-00-02-jxeqq.mongodb.net:27017/100YWeatherSmall?replicaSet=Cluster0-shard-0” --authenticationDatabase admin --ssl --username m001-student–password m001-studen
t
MongoDB shell version v4.0.4
Enter password:
connecting to: mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/
100YWeatherSmall?replicaSet=Cluster0-shard-0
2018-11-08T08:50:28.645+0800 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-0
0-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017
2018-11-08T08:50:31.224+0800 I NETWORK [js] Successfully connected to cluster0-shard-00-00-jxeqq.mongodb.net:27017 (1 connections now open to cluster0-shard-00
-00-jxeqq.mongodb.net:27017 with a 5 second timeout)
2018-11-08T08:50:31.822+0800 I NETWORK [ReplicaSetMonitor-TaskExecutor] Successfully connected to cluster0-shard-00-02-jxeqq.mongodb.net:27017 (1 connections n
ow open to cluster0-shard-00-02-jxeqq.mongodb.net:27017 with a 5 second timeout)
2018-11-08T08:50:32.657+0800 I NETWORK [js] Successfully connected to cluster0-shard-00-01-jxeqq.mongodb.net:27017 (1 connections now open to cluster0-shard-00
-01-jxeqq.mongodb.net:27017 with a 5 second timeout)
Implicit session: session { “id” : UUID(“c34ba787-88f9-44bc-b466-a659c113d862”) }
MongoDB server version: 3.6.8
WARNING: shell and server versions do not match
2018-11-08T08:50:35.192+0800 E QUERY [js] Error: Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1685:20
@(auth):6:1
@(auth):1:2
exception: login failed

The error tells you: “authentication failed”, so you know to at least double check the username and password specifications.

I notice the you’re missing a space between the username and the password spec and the password flag starts with — instead of --.

2 Likes

Hi goutham_20853,

The username and password are different parameters that need to have a space between them.

Use this command:

mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/test?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

Kanika

1 Like

Thanks Kabila.it is working now