MongoDB Quick Start _mongodb

Source: Internet
Author: User
Tags mongodb mongodb client win32

Interested in the MongoDb document database, to install the understanding.

To the official download win version http://www.mongodb.org/display/DOCS/Downloads is currently the latest stable version of 1.2.4. Extract to f:/sofr/mongodb-win32-i386-1.2.4.

Start Mongod

Copy Code code as follows:

F:\soft\mongodb-win32-i386-1.2.4>bin\mongod.exe--dbpath=f:/mongodb
Mon Mar 11:13:17 Mongo DB:starting:pid = 0 Port = 27017 DBPath = F:/mongodb Master = 0 Slave
= 0 32-bit

* * Note:when using MongoDB bit, are limited to about 2 gigabytes of data
* * Http://blog.mongodb.org/post/137788967/32-bit-limitations for more

Mon Mar 11:13:18 db version v1.2.4, pdfile version 4.5
Mon Mar 11:13:18 git version:5cf582d3d96b882c400c33e7670b811ccd47f477
Mon Mar 11:13:18 sys info:windows (5, 1, 2600, 2, ' Service Pack 3 ') boost_lib_version=1_35
Mon Mar 11:13:18 waiting for connections on port 27017

--dbpath Specify the directory of the database, the default is/data/db,win no/data/db directory, so direct double-click Mongod is not started. The default port is 27017

Linux I use the legacy-static version, because the source code compilation did not succeed.

After the server is started, it has a client (MongoDB shell) to try it out with the client. Bin/mongo.exe
Copy Code code as follows:

F:\soft\mongodb-win32-i386-1.2.4>bin\mongo.exe
MongoDB Shell version:1.2.4
Url:test
Connecting To:test
Type ' exit ' to exit
Type ' help ' for help
> Use test
Switched to DB test
> Db.foo.save ({a:1})
> Db.foo.find ()
{"_id": ObjectId ("4b946bc03f78000000001542"), "a": 1}
>

Mongod.exe the back end can see the log.
MongoDB client rich, I use Python to try (install please see: http://api.mongodb.org/python/1.4%2B/installation.html). Install Pymongo

Copy Code code as follows:

Easy_install Pymongo


Copy Code code as follows:

From Pymongo import Connection
Connection = connection ()
db = Connection.test
For f in Db.foo.find ():
Print "a=%s, _id=%s"% (f[' a '], f[' _id '])

can see the results. a=1.0, _id=4b946bc03f78000000001542. _ID is the field within the MONGO.

It's like SQL queries are more appealing ...
Original: http://blog.chenlb.com/2010/03/mongodb-quick-start.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.