I am currently taking the m220 lecture for javascript developer, and i am having issues connecting with my Atlas sandbox, I get the following output when I try to connect. my connection string is in bold.
C:\Users\OLAMI\Desktop\Coding Files\Database\MONGO LECTURES\mflix-js (2)>**mongo "mongodb+srv://m220student: m220password@mflix-4prbz.mongodb.net/test?retryWrites=true"**
MongoDB shell version v4.0.6
connecting to: mongodb://mflix-shard-00-00-4prbz.mongodb.net.:27017,mflix-shard-00-01-4prbz.mongodb.net.:27017,mflix-shard-00-02-4prbz.mongodb.net.:27017/test?authSource=admin&gssapiServiceName=mongodb&replicaSet=mflix-shard-0&retryWrites=true&ssl=true
2019-04-13T07:10:53.729+0100 I NETWORK [js] Starting new replica set monitor for mflix-shard-0/mflix-shard-00-00-4prbz.mongodb.net.:27017,mflix-shard-00-01-4prbz.mongodb.net.:27017,mflix-shard-00-02-4prbz.mongodb.net.:27017
2019-04-13T07:10:55.190+0100 I NETWORK [ReplicaSetMonitor-TaskExecutor] Successfully connected to mflix-shard-00-00-4prbz.mongodb.net.:27017 (1 connections now open to mflix-shard-00-00-4prbz.mongodb.net.:27017 with a 5 second timeout)
2019-04-13T07:10:55.300+0100 I NETWORK [js] Successfully connected to mflix-shard-00-02-4prbz.mongodb.net.:27017 (1 connections now open to mflix-shard-00-02-4prbz.mongodb.net.:27017 with a 5 second timeout)
2019-04-13T07:10:55.397+0100 I NETWORK [ReplicaSetMonitor-TaskExecutor] changing hosts to mflix-shard-0/mflix-shard-00-00-4prbz.mongodb.net:27017,mflix-shard-00-01-4prbz.mongodb.net:27017,mflix-shard-00-02-4prbz.mongodb.net:27017 from mflix-shard-0/mflix-shard-00-00-4prbz.mongodb.net.:27017,mflix-shard-00-01-4prbz.mongodb.net.:27017,mflix-shard-00-02-4prbz.mongodb.net.:27017
2019-04-13T07:10:56.333+0100 I NETWORK [js] Successfully connected to mflix-shard-00-00-4prbz.mongodb.net:27017 (1 connections now open to mflix-shard-00-00-4prbz.mongodb.net:27017 with a 5 second timeout)
2019-04-13T07:10:56.371+0100 I NETWORK [ReplicaSetMonitor-TaskExecutor] Successfully connected to mflix-shard-00-01-4prbz.mongodb.net:27017 (1 connections now open to mflix-shard-00-01-4prbz.mongodb.net:27017 with a 5 second timeout)
2019-04-13T07:10:57.430+0100 I NETWORK [ReplicaSetMonitor-TaskExecutor] Successfully connected to mflix-shard-00-02-4prbz.mongodb.net:27017 (1 connections now open to mflix-shard-00-02-4prbz.mongodb.net:27017 with a 5 second timeout)
2019-04-13T07:10:57.818+0100 I NETWORK [js] Marking host mflix-shard-00-00-4prbz.mongodb.net:27017 as failed :: caused by :: Location40659: can’t connect to new replica set master [mflix-shard-00-00-4prbz.mongodb.net:27017], err: Location8000: bad auth Authentication failed.
2019-04-13T07:10:58.241+0100 I NETWORK [js] Marking host mflix-shard-00-02-4prbz.mongodb.net:27017 as failed :: caused by :: SocketException: can’t authenticate against replica set node mflix-shard-00-02-4prbz.mongodb.net:27017 :: caused by :: socket exception
[CONNECT_ERROR] server [mflix-shard-00-02-4prbz.mongodb.net:27017] connection pool error: network error while attempting to run command ‘isMaster’ on host 'mflix-shard-00-02-4prbz.mongodb.net:27017’
2019-04-13T07:10:58.640+0100 I NETWORK [js] Marking host mflix-shard-00-01-4prbz.mongodb.net:27017 as failed :: caused by :: SocketException: can’t authenticate against replica set node mflix-shard-00-01-4prbz.mongodb.net:27017 :: caused by :: socket exception
[CONNECT_ERROR] server [mflix-shard-00-01-4prbz.mongodb.net:27017] connection pool error: network error while attempting to run command ‘isMaster’ on host 'mflix-shard-00-01-4prbz.mongodb.net:27017’
2019-04-13T07:11:00.091+0100 I NETWORK [js] Marking host mflix-shard-00-00-4prbz.mongodb.net:27017 as failed :: caused by :: Location40659: can’t connect to new replica set master [mflix-shard-00-00-4prbz.mongodb.net:27017], err: Location8000: bad auth Authentication failed.
2019-04-13T07:11:00.092+0100 E QUERY [js] Error: can’t authenticate against replica set node mflix-shard-00-00-4prbz.mongodb.net:27017 :: caused by :: can’t connect to new replica set master [mflix-shard-00-00-4prbz.mongodb.net:27017], err: Location8000: bad
auth Authentication failed. :
connect@src/mongo/shell/mongo.js:343:13
@(connect):1:6
exception: connect failed
Best Answer
To connect with MongoDB atlas from the command line as first you have to Sign In the MongoDB Atlas cluster with your login credentials.
After login in Atlas cluster connect with your cluster name and click on connect button.
Then click on Connect with the
Mongo Shell
Then according to your environment setup choose the appropriate mongo shell (as in my place I have been already installed the MongoDB v4.0.8. So, I have choose the (I have the Mongo Shell installed) then copy the command
Note: Here I have written
xxxxx
due to the security reason. In your sandbox there will be different address (Everyone will have different address of his/her cluster)If you have installed the MongoDB then open the command prompt with MongoDB BIN directory path. Which is as shown below
Here, you can see that I am able to connect with MongoDB Atlas cluster with mongo shell.
For further your ref here