MongoDB Quick Start

Source: Internet
Author: User
Tags mongodb 32 bit mongodb client

If you are interested in MongoDb document databases, you need to install them.

Download to the official Windows version of http://www.mongodb.org/display/DOCS/Downloads is currently the latest stable version is 1.2.4. Unzip to f:/sofr/mongodb-win32-i386-1.2.4.

Start mongod

Copy codeThe Code is as follows: F: \ soft \ mongodb-win32-i386-1.2.4> bin \ mongod.exe -- dbpath = f:/mongodb
Mon Mar 08 11:13:17 Mongo DB: starting: pid = 0 port = 27017 dbpath = f:/mongodb master = 0 slave
= 0 32-bit

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

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

-- Dbpath specifies the database directory. The default value is/data/db. win does not have the/data/db directory. Therefore, you cannot start mongod by double-clicking it. The default port is 27017.

In linux, I use legacy-static because the source code compilation fails.

After the server is started, use the client to try it out. It comes with a client (MongoDB shell ). Bin/cmd.exeCopy codeThe Code is as follows: F: \ soft \ mongodb-win32-i386-1.2.4> bin \ cmd.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 ("4b946bc03f781_1_1542"), "a": 1}
>

Mongod.exe logs can be viewed at the backend.
MongoDB client is rich, I try it with python (see http://api.mongodb.org/python/1.4%2B/installation.html for installation ). Install pymongo

Copy codeThe Code is as follows: easy_install pymongo Copy codeThe Code is 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'])

The result is displayed. A = 1.0, _ id = 4b946bc03f781_1542. _ Id is the internal field of mongo.

Its query like SQL is quite attractive ......
Original article: 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.