资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

MonGo---安装及其基本操作

1、安装Mongo数据库:

为镇赉等地区用户提供了全套网页设计制作服务,及镇赉网站建设行业解决方案。主营业务为做网站、成都网站制作、镇赉网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

在发布本文的时间官方提供的最新版本是:1.6.5 ,如果不做特殊声明,本教程所用的版本将会是这个版本。

  1. 第一步:下载安装包:官方下载地址←单击此处,如果是win系统,注意是64位还是32位版本的,请选择正确的版本。

  2. 第二步:新建目录“D:\MongoDB”,解压下载到的安装包,找到bin目录下面全部.exe文件,拷贝到刚创建的目录下。

  3. 第三步:在“D:\MongoDB”目录下新建“data”文件夹,它将会作为数据存放的根文件夹。

 配置Mongo服务端:

打开CMD窗口,按照如下方式输入命令:
  > d:
  > cd D:\MongoDB
  > mongod --dbpath D:\MongoDB\data

在浏览器输入:http://localhost:27017/,可以看到如下提示:
  You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number

2、基本操作:

创建\使用数据库:

> use mongotest

switched to db mongotest

显示数据表:

> show tables;

插入数据:

> item={"Key":"1","text":"wokao","number":3}

{ "Key" : "1", "text" : "wokao", "number" : 3 }

> db.wang.insert(item)

查询数据:

> db.wang.find();

{ "_id" : ObjectId("52c7812912eae9cca2c31826"), "Key" : "1", "text" : "wokao", "number" : 3 }

> item={"Key":"1","text":"wokao"}

{ "Key" : "1", "text" : "wokao" }

> db.wang.insert(item)

> db.wang.find();

{ "_id" : ObjectId("52c7812912eae9cca2c31826"), "Key" : "1", "text" : "wokao", "number" : 3 }

{ "_id" : ObjectId("52c7814912eae9cca2c31827"), "Key" : "1", "text" : "wokao" }

> show tables;

system.indexes

wang

> db.system.indexes.find();

{ "v" : 1, "key" : { "_id" : 1 }, "ns" : "mongotest.wang", "name" : "_id_" }

数据删除:

> db.wang.remove({ "_id" : ObjectId("52c7812912eae9cca2c31826")})

> db.wang.find();

{ "_id" : ObjectId("52c7814912eae9cca2c31827"), "Key" : "1", "text" : "wokao" }

数据修改:

> db.wang.find();

{ "_id" : ObjectId("52c7814912eae9cca2c31827"), "Key" : "1", "text" : "wokao" }

> var t=db.wang.findone({"Key" : "1"})

Sat Jan 04 11:42:29.671 TypeError: Property 'findone' of object mongotest.wang is not a function

> var t=db.wang.findOne({"Key" : "1"})

> t.text="wo shi ni yeye!!"

wo shi ni yeye!!

> db.wang.update({"Key" : "1"},t)

> db.wang.find();

{ "_id" : ObjectId("52c7814912eae9cca2c31827"), "Key" : "1", "text" : "wo shi ni yeye!!" }


新闻标题:MonGo---安装及其基本操作
分享链接:http://cdkjz.cn/article/ipihio.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220