1

I am connecting to MongoDB hosted on EC2 instance of AWS. I am connecting through ssh command. Upon entering the command "show collections", I am getting uncaught exceptions. Please see the sequence below. Can you let me know how can I start seeing the collections again when putting in the "Show collections" command?

show dbs admin 0.031GB cool_db (empty) local 0.031GB users 0.031GB use users switched to db users show collections 2019-08-26T18:46:15.280+0000 E QUERY [js] uncaught exception: Error: listCollections failed: { "ok" : 0, "errmsg" : "no such cmd: listCollections", "code" : 59, "bad cmd" : { "listCollections" : 1, "filter" : {

    },
    "nameOnly" : true,
    "authorizedCollections" : true
}

} : _getErrorWithCode@src/mongo/shell/utils.js:25:13 DB.prototype._getCollectionInfosCommand@src/mongo/shell/db.js:834:15 DB.prototype._getCollectionNamesInternal@src/mongo/shell/db.js:906:12 DB.prototype.getCollectionNames@src/mongo/shell/db.js:915:12 shellHelper.show@src/mongo/shell/utils.js:893:9 shellHelper@src/mongo/shell/utils.js:790:15 @(shellhelp2):1:1

5
  • Can you edit your question to include the output of version() and db.version() in the mongo shell? It looks like you are using a newer version of the mongo shell with an older (pre-3.0) version of MongoDB server. The major version of shell & server (x.y) should ideally match.
    – Stennie
    Aug 27, 2019 at 3:21
  • The version on shell is 4.2 and the version on server is 3.6. Didn't know that could cause an issue. Is there a way to fix this without uninstalling and re-installing the mongodb?
    – RB17
    Aug 27, 2019 at 15:26
  • The listCollections command was added in MongoDB 3.0 so this would be an unexpected error for a 3.6 server. Are you sure the server is 3.6? What is the exact server version (x.y.z)? If you are connecting via ssh and running mongo on the remote host (where the mongod is), it also seems unusual to have a different version of the shell from the server. Are you port forwarding ssh? The easiest fix to ensure compatibility would be installing a matching version of the mongo shell. Your 4.2 shell should be displaying a message on startup: WARNING: shell and server versions do not match.
    – Stennie
    Aug 27, 2019 at 20:31
  • Yes, I am getting the warning that you have mentioned above. The MongoDB server version is 2.6.12 not 3.6. Apologies. Is there a way to upgrade the Mongo server version through some shell command?
    – RB17
    Aug 27, 2019 at 21:27
  • Upgrading the MongoDB server requires access to the host environment, so you could upgrade via a Linux bash shell but would not be able to do so only using the mongo shell. MongoDB 2.6 reached End of Life in Oct 2016, so you definitely should be planning to upgrade. In the interim I would download a 2.6 version of the mongo shell as a lot has changed since then.
    – Stennie
    Aug 28, 2019 at 2:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.