I started working with mongodb yesterday and can't seem to generate a database on the console. Every time I do the
use exampledb
switched to db exampledb
but for some reason I still generate only my locals..?
show dbs
local 0.078GB
I created a folder called /data/db in my root directory (following the tutorial) so I'm not sure what I am missing... help appreciated!
You are not missing anything. exampledb
will be shown (using show dbs
) only when you insert atleast one document in it. You can add collections manually if you want using db.createCollection()
.
Your database need to have atleast one document inside. First we need to add atleast one document into the selected database.
Example:
db.mycollection.insert({"name":"Max"})
where db
is the general term not the name of the database and mycollection
is the name of your collection, inside the insert give as key value pairs)
After that you can see your database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With