3 default database in MongoDB

Connect with

default databae in MongoDBThere is three default database in MongoDB. 1. local database used for storing metadata for that node where MongoDB installed, this DB will not be part of replication, 2. admin database used for authentication, authorization, and administrative purpose, 3. config database used for storing of metadata for sharding.

All of you must know about its internal database of MongoDB i.e. default database of MongoDB. If you are a MongoDB user you should know, what all are the default database in MongoDB or you can say the internal default database in MongoDB.

1. Overview of default database in MongoDB

Database in the MongoDB is a set of collections in MongoDB. If you would like to know more about Collection in MongoDB, you can visit my other article What is Collection in MongoDB?.

There are 2 sets of the database in the node of mongoDB instance,

  1. default database or reserve databases: local, admin, and config.
  2. user created databse

2. how to get list of database?

Following are the mongoShell command to get list of created database in mongoDB for the node, from which you have connected.

show dbs;

the output of console as:

> show dbs;
admin      0.000GB
config     0.000GB
local      0.000GB

When you type "show dbs" command from you mongos terminal you can get a list of the database with storage size. As per my experience, most of the concept and admin command picked from opensource mySQL database, so you can coorelate and remember too, if you know mySQL basic things.

3. Internal database: local Database

In MongoDB, there is a local database that is a reserved database used to store the metadata of the replication process and other related data. This local database is not part of the replication database, meaning that, the collection in local database will not replicate from the primary node of MongoDB to the secondary node of MongoDB.

On startup, each mongod instance , mongoDB engine inserts a document into startup_log collection of local database and this information will be helpful for diagostic purpose. The collection startup_log is a capped collection. The information stored in local collection will be useful at the time when you do primary diagonstic. We can’t do readWrite on this startup_log collection.

> use local
switched to db local
> show collections
> db.startup_log.find().pretty();
        "_id" : "DESKTOP-AJRAAJK-1607882562522",
        "hostname" : "DESKTOP-AJRAAJK",
        "startTime" : ISODate("2020-12-13T18:02:42Z"),
        "startTimeLocal" : "Sun Dec 13 23:32:42.522",
        "cmdLine" : {
                "config" : "C:\\Program Files\\MongoDB\\Server\\4.4\\bin\\mongod.cfg",
                "net" : {
                        "bindIp" : "",
                        "port" : 27017
                "service": true,
                "storage" : {
                        "dbPath" : "C:\\Program Files\\MongoDB\\Server\\4.4\\data",
                        "journal" : {
                                "enabled" : true
                "systemLog" : {
                        "destination" : "file",
                        "logAppend" : true,
                        "path" : "C:\\Program Files\\MongoDB\\Server\\4.4\\log\\mongod.log"
        "pid" : NumberLong(8700),
        "buildinfo" : {
                "version" : "4.4.2",
                "gitVersion" : "15e73dc5738d2278b688f8929aee605fe4279b0e",
                "targetMinOS" : "Windows 7/Windows Server 2008 R2",
                "modules" : [ ],
                "allocator" : "tcmalloc",
                "javascriptEngine" : "mozjs",
                "sysInfo" : "deprecated",
                "versionArray" : [
                "openssl" : {
                        "running" : "Windows SChannel"
                "buildEnvironment" : {
                        "distmod" : "windows",
                        "distarch" : "x86_64",
                        "cc" : "cl: Microsoft (R) C/C++ Optimizing Compiler Version 19.26.28806 for x64",
                        "ccflags" : "/nologo /EHsc /W3 /wd4068 /wd4244 /wd4267 /wd4290 /wd4351 /wd4355 /wd4373 /wd4800 /wd5041 /wd4291 /we4013 /we4099 /we4930 /WX /errorReport:none /MD /O2 /Oy- /bigobj /utf-8 /permissive- /Zc:__cplusplus /Zc:sizedDealloc /volatile:iso /diagnostics:caret /std:c++17 /Gw /Gy /Zc:inline",
                        "cxx" : "cl: Microsoft (R) C/C++ Optimizing Compiler Version 19.26.28806 for x64",
                        "cxxflags" : "/TP",
                        "linkflags" : "/nologo /DEBUG /INCREMENTAL:NO /LARGEADDRESSAWARE /OPT:REF",
                        "target_arch" : "x86_64",
                        "target_os" : "windows",
                "bits" : 64,
                "debug" : false,
                "maxBsonObjectSize" : 16777216,
                "storageEngines" : [

4. admin database in mongoDB

The admin database plays a vital role in authentication and authorization of MongoDB database users. And this admin database is used for administrative purpose too.
There are different security mechanisms to enable security in MongoDB. If you have enabled security in MongoDB for authentication and authorization of MongoDB database user then this admin db comes into the picture. Enabling authentication and authorization is optional, however, it’s always recommended to enable for authentication of database users for establishing a connection from your client in the production environment, it could be your application, your client app i.e. RoboMongo.

> use admin
switched to db admin
> show collections
> db.system.version.find();
{ "_id" : "featureCompatibilityVersion", "version" : "4.4" }

5. config database in MongoDB

The config mongoDB database is use to store the information related to sharding and its metadata.
If you have a standalone MongoDB server then this config database is not applicable for you. Even if, your MongoDB servers running under the Replica set, it will apply to you. This is applicable for only sharing environment.

> use config
switched to db config
> show collections
> db.system.sessions.find().pretty();
        "_id" : {
                "id" : UUID("5d3d83a1-8c8a-4c1f-807f-f488ea93cf2b"),
                "uid" : BinData(0,"47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=")
        "lastUse" : ISODate("2020-12-13T18:42:42.883Z")

6. Naming convention of database in MongoDB

Following are the key points about naming convention about the database in MongoDB.

  • database name can not be empty character i.e. “”.
  • database name can be alphanumeric character .
  • database name can’t be characters: “/\. lt;>:;?*”
  • database name is case-insensitive, capital and small both are equal programmatically
  • database name can’t be more than 64 byts.
  • namespace: “dbName.collectionName” can’t be more than 120 bytes.
> mongo
  show dbs;

7. Conclusion

In a nut-shell all the three default database:

  • local: used to store meta data if local instance
  • admin: security & its previledge information and sharding medata data
  • config: for storing sharding medata

namespace: dbName.collectionName


namespace: dbName.collectionName


Referece: MongoDB official site
Your comments are welcome which encourage me to add more post and improvement too. Please share your thought, how you find this internal database in mongoDB i.e. default database in MongoDB. Happy Learning!

Connect with

Leave a Comment

Your email address will not be published. Required fields are marked *