Finally determined to buy in some East "Python core programming (ii)" and "Bird Brother Linux, Basic (iii)". It feels like learning Linux is better at first or in a virtual machine, so install VirtualBox and download the cent OS 7. Install cent OS found completely no GUI Ah, fortunately, before using a period of time Ubuntu, feel okay.
(i) installation under the Windows system
(1) Download, the official website is http://www.mongodb.org/do not go to the COM that. Download the 2.4 stable version.
(2) Download the zip file and unzip it. Create a new MongoDB on the D drive and move the extracted files to MongoDB. You then create a new data and logs in the MongoDB folder, which you can use to place the file and the log file separately.
(3) Open cmd and run the following command to start the MongoDB service.
D:\mongodb\bin>mongod --dbpath d:/mongodb/datafri sep 12 00:58:22.054fri sep 12 00:58:22.054 warning: 32-bit servers don ' t have journaling Enabled by default. please use --journal if you want durability. Fri sep 12 00:58:22.054fri sep 12 00:58:22.074 [initandlisten] mongodb starting : pid=392 port=27017 dbpath=d:/mongodb/data 32-bit host= lenovo-pcfri sep 12 00:58:22.074 [initandlisten]fri sep 12 00:58:22.074 [initandlisten] ** note: this is a 32 bit mongodb binary. fri sep 12 00:58:22.074 [initandlisten] ** 32 bit builds are limited to less than 2gb of data (or less with --journal). fri sep 12 00:58:22.074 [initandlisten] ** note that journaling defaults to off for 32 bit and is Currently off. fri sep 12 00:58:22.074 [initandlisten] ** See http://dochub.mongodb.org/core/32bitfri sep 12 00:58:22.074 [initandlisten]fri sep 12 00:58:22.074 [initandlisten] db version v2.4.11fri sep 12 00:58:22.074 [initandlisten] git version: Fa13d1ee8da0f112f588570b4070f73d7af2f7fdfri sep 12 00:58:22.074 [initandlisten] build info: windows sys.getwindowsversion (major=6, minor=0, build=6002, platform=2, service_pack= ' service pack 2 ') BOOST_LIB_VERSION=1_49Fri Sep 12 00:58:22.084 [initandlisten] allocAtor: systemfri sep 12 00:58:22.084 [initandlisten] options: { dbpath: "D:/mongodb/data" }Fri Sep 12 00:58:22.164 [websvr] admin web console waiting for connections on port 28017fri sep 12 00:58:22.164 [initandlisten] waiting for connections on port 27017# As you can see, MongoDB Web and connections ports are 28017 and 27017.# respectively in the browser address bar, input 127.0.0.1:28017 and 127.0.0.1:27017 can see
Mongo.exe is the MongoDB interactive shell
(4) It is inconvenient to start the service so that the MongoDB service can be set as Windows system service
D:\mongodb\bin>mongod--logpath d:/mongodb/logs/mongodb.log--logappend--dbpath D:/mongodb/data--directoryperdb --servicename MongoDB--install
This allows the MongoDB service to be found in the Windows service.
net start MongoDB # Start service net stop MongoDB # Shutdown Service net Restart MongoDB # Restart Service
This is the basic installation, detailed configuration and use or need to look at the official documents and other materials.
Official Document: HTTP://DOCS.MONGODB.ORG/V2.4/
A simple code: (Need to install Pymongo module)
#!coding=utf-8import pymongo# establishes the connection con = Pymongo. Connection (' 127.0.0.1 ', 27017) # CREATE DATABASE MyDB = con.mydb# Add user mydb.add_user (' Test ', ' Test ') # User authentication mydb.authenticate (' test ') , ' Test ') # Create data table Muser = mydb.user# Insert a record Muser.save ({' id ': 1, ' name ': ' Test '}) Muser.insert ({' id ': 2, ' name ': ' Hello '}) # query A record # print muser.find_one () # for U in Muser.find (): # Print Ufor u in Muser.find (). Limit (3). Skip (2): Print Ucon.clo SE ()
NoSQL Database-MongoDB