How to list all databases in the mongo shell?

前端 未结 7 1646
灰色年华
灰色年华 2021-01-29 19:23

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

7条回答
  •  时光说笑
    2021-01-29 20:06

    To list mongodb database on shell

     show databases     //Print a list of all available databases.
     show dbs   // Print a list of all databases on the server.
    

    Few more basic commands

    use     // Switch current database to . 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.
    

提交回复
热议问题