Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (47.6k points)

I know how to list all collections in a particular database, but how do I list all available databases in MongoDB shell?

2 Answers

0 votes
by (106k points)

There are many ways of listing all the databases in the MongoDB console:-

  • So the first thing you can use the command show dbs.

For MongoDB shell version 3.0.5 insert the following command in the shell:

db.adminCommand('listDatabases')

or alternatively:

db.getMongo().getDBNames()

0 votes
by (108k points)

For database list:

show databases

show dbs

And for table/collection list:

show collections

show tables

db.getCollectionNames()

Related questions

0 votes
2 answers
asked Sep 4, 2019 in SQL by Sammy (47.6k points)
0 votes
2 answers
0 votes
2 answers
0 votes
1 answer

Browse Categories

...