If you are new to MongoDB you may need to discover the databases and collections (basically objects) on your MongoDB instance. For this easily you can use a GUI tool like MongoVUE. But in this blog post, I’m not going to describe GUI tools. I’m going to explain about MongoShell to navigate through database objects.
nn
I can remember the first day that I used Linux. In that day I fed up with Terminal and gave it up. But now I think it’s cool!.
Somehow if you want to do something easier I still recommend GUI Tools.
nFirst to execute those commands you should log into MongoShell. In windows mongo.exe.
nn
How to take database List?
nn
show dbs n
nn
How to check the database that you are currently using?
nn
db n
nn
or
nn
print(db); n
nn
How to change to a new database?
nn
use <database name> n
nn
E.g:-
nn
use AdventureWorks2012 n
nn
How to take the list of Collection in the current Database?
nn
show collections n
nn
or
nn
db.getCollectionNames(); n
nn
How to take the list of Users in Database?
nn
show users n
nn
or
nn
db.system.users.find();n
nn
Tags
nn
- n
- MongoDB
- MongoShell
- Mongo Shell
n
n
n
n