Unable to connect MongoDB atlas from MongoDB shell

Getting below errors

LTA121YN0N-MAC:~ a121yn0n$ mongo --nodb

MongoDB shell version v4.0.3

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

2019-06-30T00:29:49.573+0530 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:6

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

2019-06-30T00:30:36.957+0530 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:6

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

2019-06-30T00:31:08.494+0530 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:6

quit()

LTA121YN0N-MAC:~ a121yn0n$ 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

MongoDB shell version v4.0.3

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/test?replicaSet=Cluster0-shard-0

2019-06-30T00:31:15.777+0530 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017

2019-06-30T00:31:17.411+0530 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)

2019-06-30T00:31:17.411+0530 I NETWORK [ReplicaSetMonitor-TaskExecutor] Successfully connected to cluster0-shard-00-02-jxeqq.mongodb.net:27017 (1 connections now open to cluster0-shard-00-02-jxeqq.mongodb.net:27017 with a 5 second timeout)

2019-06-30T00:31:19.252+0530 I NETWORK [ReplicaSetMonitor-TaskExecutor] 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)

Implicit session: session { “id” : UUID(“0bee714b-b257-4c4f-b039-760efe611db3”) }

MongoDB server version: 3.6.13

WARNING: shell and server versions do not match

MongoDB Enterprise Cluster0-shard-0:PRIMARY> 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

2019-06-30T00:31:27.366+0530 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:6

MongoDB Enterprise Cluster0-shard-0:PRIMARY> mongo --nodb

2019-06-30T00:31:35.584+0530 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:8

MongoDB Enterprise Cluster0-shard-0:PRIMARY>

You are already connected to mongodb
That is why your commands failing with syntax error
If you want to connect again just exit/quit and run your command again

mongo commands should be run at os prompt not at mongo prompt

2 Likes