1. winxp 下安装
Changed in version 2.2: MongoDB does not support Windows XP.
C:\mongodb2.0.8
进入c:\
md data md data\db第二步:进入 cmd 提示符控制台,c:\mongodb2.0.8\bin\mongod.exe --dbpath=c:\data\db
第三步:将MongoDB作为 Windows 服务随机启动(也可以通过
C:\mongodb2.0.8\bin\mongod.exe启动。
md C:\mongodb2.0.8\log
echo logpath=C:\mongodb2.0.8\log\mongo.log > C:\mongodb2.0.8\mongod.cfg
install the MongoDB service: C:\mongodb2.0.8\bin\mongod.exe --config C:\mongodb2.0.8\mongod.cfg --install
run the MongoDB service: net start MongoDB
stop the MongoDB service: net stop MongoDB
remove the MongoDB service: C:\mongodb2.0.8\bin\mongod.exe --remove
第四步:
Connect to MongoDB using the mongo.exe shell. Open another Command Prompt and issue the following command: C:\mongodb\bin\mongo.exe
> db.test.save( { a: 1 } ) > db.test.find()
2. Ubuntu安装
第一步:Configure Package Management System (APT) sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 touch /etc/apt/sources.list.d/10gen.list 向10gen.list中写入: deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen sudo apt-get update 第二步:Install Packages sudo apt-get install mongodb-10gen These packages configure MongoDB using the /etc/mongodb.conf file in conjunction with the control script. You will find the control script is at /etc/init.d/mongodb. This MongoDB instance will store its data files in the /var/lib/mongodb and its log files in /var/log/mongodb, and run using the mongodb user account. sudo service mongodb start mongo > db.test.save( { a: 1 } ) > db.test.find() sudo service mongodb stop sudo service mongodb restart