Cant connect to mongo shell

Hey,

When I am trying to connect to the course database with mongo shell on windows I am getting the following error:

MongoDB Enterprise > 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/aggregations?replicaSet=Cluster0-shard-0” --authenticationDatabase admin --ssl -u m121 -p aggregations --norc
2019-11-29T09:36:13.398+0000 E QUERY [js] uncaught exception: SyntaxError: unexpected token: string literal :
@(shell):1:6

Please help.

Many Thanks,
Andrea

Hi @Andrea_Borsos_00640,

You are trying to connect to the Mongo Shell using the connection string from within the Mongo Shell.

I believe you are already connected to the cluster.
To verify you can run the following commands :

show dbs
use aggregations
show collections

Please let me know if you have any questions.

Thanks,
Sonali

Unfortnately it is not connected to the cluster, shows dbs doesnt return the db and show collections also returns empty.

Hi @Andrea_Borsos_00640,

Then try to exit from the current mongo shell and reconnect using the following connection string:

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/aggregations?replicaSet=Cluster0-shard-0” --authenticationDatabase admin --ssl -u m121 -p aggregations --norc

If you still get any error, please share the screenshot of the same.

Thanks,
Sonali

Still getting the same error, attached screenshot.

Many Thanks,
Andrea

Please follow the instructions provided by Sonali.

You clearly missing step 1.

1 Like

Hi @Andrea_Borsos_00640,

Few things to note here:

  1. if you see the prompt as follows, it means you are already connected to the Mongo Shell:

MongoDB Enterprise >

Now if you will again try to run the connection string, you will receive the error.

  1. Please try to exit from the shell first using the exit command as below:

MongoDB Enterprise > exit

Then reconnect to the shell using the above connection string as shown in the screenshot:

It is recommended to first complete the M001: MongoDB Basics course to get acquainted with the basic concepts and then move on to advanced courses like M121: Aggregation framework course.
This would further enhance your understanding of MongoDB concepts.

Please let me know, if you have any questions.

Thanks,
Sonali

1 Like