Under ubuntu, add the package "mongodb-clients" and "mongodb-server"
/etc/mongodb.conf holds the server configuration.
bind_ip tells the server which interfaces to listen on. It is comma separated.
A database holds many collections.
One mongod server may hold many databases.
> show dbs
database 0.0625GB
example 0.0625GB
exampledb 0.0625GB
rover1 0.0625GB
>
From the client, to create a 'example' database, run
> use example switched to db example
Run 'db' by itself.
> db
example
A collection holds many documents. A document can be considered a JSON object, which could have nested fields.
> use exampledb
switched to db exampledb
> show collections
animal
system.indexes
To insert into the 'animal' collection of the current database, run:
[db.animal.insert({name: "giraffe"})
It will also create the collection if it does not exist.
> db.animal.find()
The above shows documents in the 'animal' collection of the current database.
Finds all documents in the 'animal' collection where name is equal to 'giraffe'
db.animal.find({"name":"giraffe"})
> db.animal.getIndexes()
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"ns" : "exampledb.animal",
"name" : "_id_"
}
]