Rob*_*her 194
列出mongoDB控制台中的所有数据库都在使用该命令show dbs.
有关此内容的更多信息,请参阅可在mongo shell中使用的Mongo Shell Command Helpers.
小智 51
对于MongoDB shell 3.0.5版,在shell中插入以下命令:
db.adminCommand('listDatabases')
Run Code Online (Sandbox Code Playgroud)
或者:
db.getMongo().getDBNames()
Run Code Online (Sandbox Code Playgroud)
小智 49
你也可以试试这个
对于数据库列表---
show databases
show dbs
Run Code Online (Sandbox Code Playgroud)
对于表/收藏清单---
show collections
show tables
db.getCollectionNames()
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助..
Sco*_*and 29
从命令行问题
mongo --quiet --eval "printjson(db.adminCommand('listDatabases'))"
Run Code Online (Sandbox Code Playgroud)
它给出了输出
{
"databases" : [
{
"name" : "admin",
"sizeOnDisk" : 978944,
"empty" : false
},
{
"name" : "local",
"sizeOnDisk" : 77824,
"empty" : false
},
{
"name" : "meteor",
"sizeOnDisk" : 778240,
"empty" : false
}
],
"totalSize" : 1835008,
"ok" : 1
}
Run Code Online (Sandbox Code Playgroud)
在 shell 上列出 mongodb 数据库
show databases //Print a list of all available databases.
show dbs // Print a list of all databases on the server.
Run Code Online (Sandbox Code Playgroud)
更多基本命令
use <db> // Switch current database to <db>. The mongo shell variable db is set to the current database.
show collections //Print a list of all collections for current database.
show users //Print a list of users for current database.
show roles //Print a list of all roles, both user-defined and built-in, for the current database.
Run Code Online (Sandbox Code Playgroud)