MongoDB document says that db is not created till the time collection is added to it so I am curious that what is the meaning of below logs from mongod console , when context is set to new DB(mydb) . Does it mean that new DB is created with default collections ?
2015-01-11T22:02:52.352-0500 [conn1] allocating new ns file /usr/local/data/db/mydb.ns, filling with zeroes...
2015-01-11T22:02:52.392-0500 [FileAllocator] allocating new datafile /usr/local/data/db/mydb.0, filling with zeroes...
2015-01-11T22:02:52.509-0500 [FileAllocator] done allocating datafile /usr/local/data/db/mydb.0, size: 64MB, took 0.117 secs
It has been a while since I reviewed the documents, but I believe the MongoDB documents say that a database will not be permanently created until you add data to it.
As such, a temporary database is defined as soon as a connection is established, or a database name is selected in the Mongo shell.
If you close the connection without adding any data, the temporary database will disappear.
Using the Mongo shell, you can see that with the show dbs command. No database in the name you chose will initially appear.
After you add data to that database, now that temporary database becomes permanent and the database you named will appear.
This way, MongoDB is automatically ready to go for data insertion as soon as a database name is chosen.
I understand your confusion. I was confused the first time I looked at it, too.
They don't really do a good job of clarifying this "permanently" term, which I think is odd, as the setup process is very different from a traditional relationship database.
If you have any other questions, please don't hesitate to ask.