Chapter 1: Lab - $match

Hi Mongo Support,

I am getting the following issue when run the scrip below:
mongo “mongodb://,,” --authenticationDatabase admin --tls --username m121 --password aggregations --norc

MongoDB shell version v4.2.0

connecting to: mongodb://,,

2019-12-26T21:11:49.225-0500 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/,,

2019-12-26T21:11:49.225-0500 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to

2019-12-26T21:11:49.225-0500 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to

2019-12-26T21:11:49.225-0500 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to

2019-12-26T21:11:49.665-0500 I NETWORK [ReplicaSetMonitor-TaskExecutor] Confirmed replica set for Cluster0-shard-0 is Cluster0-shard-0/,,

Implicit session: session { “id” : UUID(“5796dfee-34d6-4c04-8543-2c270bfbefc5”) }

MongoDB server version: 3.6.16

WARNING: shell and server versions do not match

MongoDB Enterprise Cluster0-shard-0:PRIMARY> use movies

switched to db movies

MongoDB Enterprise Cluster0-shard-0:PRIMARY> show collections

2019-12-26T21:12:03.906-0500 E QUERY [js] uncaught exception: Error: listCollections failed: {

“operationTime” : Timestamp(1577412718, 1),

“ok” : 0,

“errmsg” : “not authorized on movies to execute command { listCollections: 1.0, filter: {}, nameOnly: true, authorizedCollections: true, lsid: { id: UUID(“5796dfee-34d6-4c04-8543-2c270bfbefc5”) }, $clusterTime: { clusterTime: Timestamp(1577412718, 1), signature: { hash: BinData(0, FEDAEEFC5F49BDDFE686E160C4A038FD2395D63C), keyId: 6730992026675838977 } }, $db: “movies” }”,

“code” : 13,

“codeName” : “Unauthorized”,

“$clusterTime” : {

“clusterTime” : Timestamp(1577412718, 1),

“signature” : {

“hash” : BinData(0,"/tru/F9Jvd/mhuFgxKA4/SOV1jw="),

“keyId” : NumberLong(“6730992026675838977”)



} :







The original script copied from Chapter 1: Lab - Match is the following:

mongo “mongodb://,,” --authenticationDatabase admin --ssl -u m121 -p aggregations --norc

I changed the -u, -p and --ssl parameters by --username, --password, --tls

Movies is not the db that we need to use. We need to use movies collection that’s inside aggregations database. Looks like you haven’t selected the aggregations db first, Try executing following steps and see if you can make it working.

After connection;

  1. use aggregations
  2. db.movies.count() / db.movies.find().pretty() (You can just make sure that movie collection is there by show tables / show collections)
1 Like

Hi viraj_thakrar,

Thanks for your support, you right, I was working on wrong database. It now is fine.

I am facing an issue while connecting to Atlas cluster via mongo shell using the command provided. I am getting this error : -
2019-12-27T19:37:14.003-0400 E QUERY [js] uncaught exception: SyntaxError: unexpected token: string literal :

Welcome @Sakshi_74753,

This is possible if you have copied command and pasting it into Ubuntu / Linux / Windows machine (sometime quotes gets change according to system’s encoding). You would have to remove quotes and add it using your keyboard. I have highlighted those in bolds, You can remove that and add it back using your keyboard after pasting it.


mongo mongodb://,, --authenticationDatabase admin --ssl -u m121 -p aggregations --norc

After making this changes try again and if its still not working. Please post the whole screenshot or log of what you’re getting on the screen. That will helpful to give you exact solution for your problem.

1 Like

Considering @Sakshi_74753’s question is not related to @Guillermo_17708’s topic, I would suggest that further discussions are continued in a new thread created by @Sakshi_74753.