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

1、安裝Mongo數(shù)據(jù)庫:

為鎮(zhèn)賚等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及鎮(zhèn)賚網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為做網(wǎng)站、成都網(wǎng)站制作、鎮(zhèn)賚網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!

在發(fā)布本文的時間官方提供的最新版本是:1.6.5 ,如果不做特殊聲明,本教程所用的版本將會是這個版本。

  1. 第一步:下載安裝包:官方下載地址←單擊此處,如果是win系統(tǒng),注意是64位還是32位版本的,請選擇正確的版本。

  2. 第二步:新建目錄“D:\MongoDB”,解壓下載到的安裝包,找到bin目錄下面全部.exe文件,拷貝到剛創(chuàng)建的目錄下。

  3. 第三步:在“D:\MongoDB”目錄下新建“data”文件夾,它將會作為數(shù)據(jù)存放的根文件夾。

 配置Mongo服務(wù)端:

打開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、基本操作:

創(chuàng)建\使用數(shù)據(jù)庫:

> use mongotest

switched to db mongotest

顯示數(shù)據(jù)表:

> show tables;

插入數(shù)據(jù):

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

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

> db.wang.insert(item)

查詢數(shù)據(jù):

> 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_" }

數(shù)據(jù)刪除:

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

> db.wang.find();

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

數(shù)據(jù)修改:

> 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---安裝及其基本操作
文章URL:http://muchs.cn/article0/ipihio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、App開發(fā)網(wǎng)站內(nèi)鏈、品牌網(wǎng)站制作、品牌網(wǎng)站設(shè)計、用戶體驗

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司