mongodb - command 'show collection' doesn't show anything - mongodb

I switched my db properly and also confirmed that there is a document in my collection but I cannot find any collection by 'show collection' command.
Can I know the reason?

Please check your Mongo shell version and MongoDB version are compatible.
Refer to this JIRA ticket which has the similar issue reported. The root cause of the problem was the Mongo shell version and MongoDB version were not compatible.
To get Mongo Shell version:-
Go to the bin folder and execute mongo command which will print the Mongo shell version in the first line.
To get MongoDB version:-
db.version()

Related

Shell logging for mongodb

I am new to mongodb and trying to figure out a lot.
Can we configure shell logging for mongodb? What I mean is the capability to get logs from the Shell to track queries for auditing purposes for version 4?
If so - what commands do we have to run please?
Thank you for your help
There are two versions of MongoDB shell: the newer mongosh and the older/legacy mongo shell.
mongo maintains a history of commands in the .dbshell file. For example, in the Windows 7 environment this can be found at the folder: C:\Users\<user_name>
MongoDB Shell mongosh stores logs for each session and can be retrieved as explained at: Retrieve Shell Logs. For example, in Windows environment this can be found at the folder: C:\Users\<user_name>\AppData\Local\. The log files are of the format <LogID>_log.

Before Mongo 3.2 which method was used to find

I have an installation of Mongo v3.0.15 and I cannot execute the find command from my application. I need to build this with backward compatibility, so, which command was used instead of find for previous versions of Mongo 3.2?
The current error that I receive from Mongo is:
find command not yet implemented
mongo driver: gopkg.in/mgo.v2
Then am trying to retrieve records using:
s.session.DB("").Run(rawQuery, &queryResult)

mongodb 3.2.11, version too new for this mongod

I have an issue with mongodb server. I am using version 3.2.11.
Unable to find metadata for table:index-3--5957523542490303670 Index: {name: id, ns: dashboard.dataaas} - version too new for this mongod
I have already update mongo version to 3.4, but it still could not start the server on, the error still remains.
I would like to delete that index / table, but I could not log in to mongo-shell. And could not found file index-3--5957523542490303670 in any of folder
Please help
Basically as error states, mongo client/shell as well as mongod server should have the same version. You can check the mongo shell version using mongo --version. If it does not match, downgrade/upgrade client as required.
Also check if server is running.

Can't retrieve MongoDB collection in Git Bash (Windows)

This is the exact steps that I followed:
User#User-PC MINGW64 /
$ mongo
2016-02-22T10:02:33.474+0800 I CONTROL [main] Hotfix KB2731284 or later update is not installed, will zero-out data files
MongoDB shell version: 3.2.3
connecting to: test
use dev
switched to db dev
show collections
Building
_SCHEMA
db.building.find()
After doing db.building.find nothing outputs; no error, nothing.
Maybe I'm trying to fetch the collection in the wrong way?
The collection name is Building, so please try
db.Building.find({})
rather than
db.building.find()

how is mongodb server name selected?

~$ mongo
MongoDB shell version: 2.2.3
connecting to: test
>
why is my server name test? and where can I change it?
'test' is the default database.
You can change current db with the help of use command.
use NewDatabaseName
If "NewDatabaseName" is not exist it will be created in Mongo.