A command to show the db I'm currently using in MongoDB?

What is the command to display the current db in the MongoDB shell?

(I did not find it on Google)

+60
mongodb
Apr 14 '13 at 20:49
source share
3 answers

Found it, guessing :) Just:

db

+106
Apr 14 '13 at 20:52
source share

The command to get the database name in the shell:

 > db.getName() 

While you just type db, you will find that this only works interactively, and if you work with a script, this may not give the desired result.

+36
Apr 15 '13 at 3:13
source share

db.current

this is a CLI command that will show you the database you are currently working in

+1
Jan 30 '19 at 3:44
source share



All Articles