MongoDB is an open source, high-performance, open source NoSQL database.
Compared to relational DBMS, Mongodb is quite different. In MongoDB you store JSON-like documents with dynamic schemas.
Install mongodb depending on the OS you are working on.
Here is the link where you can download them
http://www.mongodb.org/display/DOCS/Quickstart
I have Installed mongodb directly from ubuntu software center.
after installation restart the mongo server
> sudo service mongodb start
You may prompted with "start: Job is already running: mongodb". This means mongo server was already running.
run the below command to connect to mongodb
> mongo
MongoDB shell version: 1.8.2
Tue Jul 3 12:41:59 *** warning: spider monkey build without utf8 support. consider rebuilding with utf8 support
connecting to: test
In the above case mongodb by default connect to test database.
lets now create your first record as below
> db.test.save({a: 1})
The above command will create record in database. To view the record just run the find statement as below
> db.test.find({a: 1})
{ "_id" : ObjectId("4ff29c16ab6b02ddb38d978a"), "a" : 1 }
create second record by adding another column parameter
> db.test.save({b: 1, name: 'uma mahesh'})
to view the record
> db.test.find({b: 1})
{ "_id" : ObjectId("4ff29c41ab6b02ddb38d978b"), "b" : 1, "name" : "uma mahesh" }
to find all the records that were created, just run the below command
> db.test.find()
{ "_id" : ObjectId("4ff29c16ab6b02ddb38d978a"), "a" : 1 }
{ "_id" : ObjectId("4ff29c41ab6b02ddb38d978b"), "b" : 1, "name" : "uma mahesh" }
To view list of all databases in mongodb, run the below command
> show dbs
Thsi will display list of databases as below
admin (empty)
local (empty)
test 0.0625GB
Thank You,
Uma Mahesh.
Compared to relational DBMS, Mongodb is quite different. In MongoDB you store JSON-like documents with dynamic schemas.
Install mongodb depending on the OS you are working on.
Here is the link where you can download them
http://www.mongodb.org/display/DOCS/Quickstart
I have Installed mongodb directly from ubuntu software center.
after installation restart the mongo server
> sudo service mongodb start
You may prompted with "start: Job is already running: mongodb". This means mongo server was already running.
run the below command to connect to mongodb
> mongo
MongoDB shell version: 1.8.2
Tue Jul 3 12:41:59 *** warning: spider monkey build without utf8 support. consider rebuilding with utf8 support
connecting to: test
In the above case mongodb by default connect to test database.
lets now create your first record as below
> db.test.save({a: 1})
The above command will create record in database. To view the record just run the find statement as below
> db.test.find({a: 1})
{ "_id" : ObjectId("4ff29c16ab6b02ddb38d978a"), "a" : 1 }
create second record by adding another column parameter
> db.test.save({b: 1, name: 'uma mahesh'})
to view the record
> db.test.find({b: 1})
{ "_id" : ObjectId("4ff29c41ab6b02ddb38d978b"), "b" : 1, "name" : "uma mahesh" }
to find all the records that were created, just run the below command
> db.test.find()
{ "_id" : ObjectId("4ff29c16ab6b02ddb38d978a"), "a" : 1 }
{ "_id" : ObjectId("4ff29c41ab6b02ddb38d978b"), "b" : 1, "name" : "uma mahesh" }
To view list of all databases in mongodb, run the below command
> show dbs
Thsi will display list of databases as below
admin (empty)
local (empty)
test 0.0625GB
Thank You,
Uma Mahesh.
No comments:
Post a Comment