1,下载mongodb压缩包http://downloads.mongodb.org/win32/mongodb-win32-i386-2.0.4.zip;
2,解压到指定目录,例如:c:\mongo;
3,启动mongodb。首先,需要建立两个目录,一个是日志目录c:\mongo\logs\logs.log,一个是存放数据文件的目录c:\mongo_data,然后打开cmd命令行,进入到c:\mongo\bin\目录下,然后输入如下命令启动服务,c:/mongo/bin>mongod.exe --dbpath c:/mongo_data,显示:
C:\mongo\bin>mongod --dbpath c:\mongo_data
Wed Apr 11 12:23:38
Wed Apr 11 12:23:38 warning: 32-bit servers don't have journaling enabled by def
ault. Please use --journal if you want durability.
Wed Apr 11 12:23:38
Wed Apr 11 12:23:38 [initandlisten] MongoDB starting : pid=4756 port=27017 dbpat
h=c:\mongo_data 32-bit host=20111027-1247
Wed Apr 11 12:23:38 [initandlisten]
Wed Apr 11 12:23:38 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are
limited to about 2 gigabytes of data
Wed Apr 11 12:23:38 [initandlisten] ** see http://blog.mongodb.org/post/13
7788967/32-bit-limitations
Wed Apr 11 12:23:38 [initandlisten] ** with --journal, the limit is lower
Wed Apr 11 12:23:38 [initandlisten]
Wed Apr 11 12:23:38 [initandlisten] db version v2.0.4, pdfile version 4.5
Wed Apr 11 12:23:38 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506
cb21f8ebf
Wed Apr 11 12:23:38 [initandlisten] build info: windows sys.getwindowsversion(ma
jor=6, minor=0, build=6002, platform=2, service_pack='Service Pack 2') BOOST_LIB
_VERSION=1_42
Wed Apr 11 12:23:38 [initandlisten] options: { dbpath: "c:\mongo_data" }
Wed Apr 11 12:23:38 [initandlisten] waiting for connections on port 27017
Wed Apr 11 12:23:38 [websvr] admin web console waiting for connections on port 2
8017
表示启动成功,最后两行说明的数据库端口和Web端口,默认分别是27017和28017,在浏览器中打开http://localhost:28017,可以看到其相关的一些信息。 可以通过添加参数--port的方式,来修改数据库端口:c:/mongo/bin>mongod.exe --port 10001 --dbpath c:/mongo_data
4,为了方便起见,可以把mongodb的启动方式加入到windows服务中。方法是:C:\mongo\bin>mongod --logpath c:/mongo/logs/logs.log --logappend --dbpath c:/mongo_data --directoryperdb --serviceName MongoDB --install,即可。然后在服务里,就会看到MongoDB,这个服务项了。
5,MongoDB的windows下的安装就是这样。如果在php中想使用mongodb的话,还得需要下载php的mongodb插件,http://cloud.github.com/downloads/mongodb/mongo-php-driver/php_mongo-1.2.10.zip,解压到php的ext目录中,然后修改php.ini,添加extension=php_mongo.dll,重启apache就OK了。这样你的PHP里就可以使用MongoDB了。
来源:oschina
链接:https://my.oschina.net/u/243423/blog/53143