windows下安装mongodb和简单使用mongodb命令.doc_第1页
windows下安装mongodb和简单使用mongodb命令.doc_第2页
windows下安装mongodb和简单使用mongodb命令.doc_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

windows下安装mongodb和简单使用mongodb命令 windows下安装mongodb和简单使用mongodb命令一。下载,解压文件到官方下载合适的版本 /downloads例如:/win32/mongodb-win32-i386-1.6.5.zip解压后放到对应的盘符下面,例如:G:mongodb165二。安装1.把bin目录加入到环境变量中 G:mongodb165bin2.在G:mongodb165下创建data文件夹放数据用3.简单启动mongodb方法:进入到bin目录下C:Documents and SettingszhengG:G:cd mongodb165/binG:mongodb165binmongod -dbpath G:/mongodb165/dataG:mongodb165binmongod -dbpath G:/mongodb165/dataSun Jan 16 14:56:03 MongoDB starting : pid=860 port=27017 dbpath=G:/mongodb165/data 32-bit* NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data* see /post/137788967/32-bit-limitationsSun Jan 16 14:56:03 db version v1.6.5, pdfile version 4.5Sun Jan 16 14:56:03 git version: 0eb017e9b2828155a67c5612183337b89e12e291Sun Jan 16 14:56:03 sys info: windows (5, 1, 2600, 2, Service Pack 3) BOOST_LIB_VERSION=1_35Sun Jan 16 14:56:03 initandlisten waiting for connections on port 27017Sun Jan 16 14:56:03 websvr web admin interface listening on port 28017注:必须先建立data文件夹和到bin目录下执行。mongoDB 服务端的默认连接端口是 270172.添加到注册表作为Windows服务启动,和mysql一样启动Windows时会自动启动服务,到bin目录下执行G:mongodb165binmongod -logpath G:mongodb165logsmongodb165.log -logappend-dbpath G:mongodb165data -directoryperdb -serviceName mongodb165 -install完成后输出下面内容(360等杀毒软件会阻止,需要允许通过)all output going to: G:mongodb165logsmongodb165.logCreating service mongodb165.Service creation successful.Service can be started from the command line via net start mongodb165.G:mongodb165bin其中:logsmongodb165.log日志是以追加的方式输出的,-serviceName mongodb165是服务名称启动MongoDB:net start mongodb165停止MongoDB:net stop mongodb165注:添加到注册表后重启电脑在服务项里面可以看到已经启动,但服务仍然没有启动,重启服务发现给360安全卫士阻止了需要再次确定才能启动。3.mongodb的简单使用命令,到bin命令下执行mongo.exe进入管理界面,默认是进入到test帐号。G:mongodb165binmongo.exeMongoDB shell version: 1.6.5connecting to: test show dbs;adminlocal help;查看命令提示 db.help() help on db methods db.mycoll.help() help on collection methods rs.help() help on replica set methods help connect connecting to a db help help admin administrative help help misc misc things to know show dbs show database names show collections show collections in current database show users show users in current database show profile show most recent file entries with time = 1ms use set current database db.foo.find() list objects in collection foo db.foo.find( a : 1 ) list objects in foo where a = 1 it result of the last line evaluated; use to further iterate exit quit the mongo shell use testdb;切换到testdb数据库,如果不存在则在插入数据后会自动创建一个,在data目录下可以看到新增了一个testdb的文件夹switched to db testdb db.myc.save(a:10);向collection mpc 中保存一条信

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论