安裝方式
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶,將通過(guò)不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:申請(qǐng)域名、網(wǎng)頁(yè)空間、營(yíng)銷軟件、網(wǎng)站建設(shè)、東城網(wǎng)站維護(hù)、網(wǎng)站推廣。
采用apt-get install MongoDB命令直接進(jìn)行,采用源碼包安裝也可以
hadoop@dblab:/$ sudo apt-get update
hadoop@dblab:/$ sudo apt-get install -y mongodb-org
hadoop@dblab:/$ mongo -version
MongoDB shell version: 3.2.22
hadoop@dblab:/$ sudo service mongodb start #啟動(dòng)MongoDB
hadoop@dblab:/$ mongo? #進(jìn)入MongoDB Shell模式
> use school? ?#切換到shcool數(shù)據(jù)庫(kù),使用時(shí)會(huì)自動(dòng)創(chuàng)建
switched to db school
> db.createCollection('teacher')? ? #創(chuàng)建集合
{ "ok" : 1 }
> show dbs? ?#顯示數(shù)據(jù)庫(kù)列表
local? 0.000GB
school? 0.000GB
> db.student.insert({_id:1,sname:'zhangsan',sage:20})? ?#插入數(shù)據(jù)
WriteResult({ "nInserted" : 1 })
> db.student.insert({_id:2,sname:'lisi',sage:22})? ?#插入數(shù)據(jù)
WriteResult({ "nMatched" : 0, "nUpserted" : 1, "nModified" : 0, "_id" : 2 })
> use school
switched to db school
> show collections? ?#顯示當(dāng)前數(shù)據(jù)庫(kù)的集合
student
teacher
#查找數(shù)據(jù)
> db.student.find()? ?#查找所有記錄
{ "_id" : 1, "sname" : "lisi", "sage" : 22 }
{ "_id" : 2, "sname" : "lisi", "sage" : 22 }
> db.student.remove({_id: 2})? ? #刪除數(shù)據(jù)
WriteResult({ "nRemoved" : 1 })
> db.student.find()
{ "_id" : 1, "sname" : "lisi", "sage" : 22 }
> db.student.insert({_id:2,sname:'zhangsan',sage:25})
WriteResult({ "nInserted" : 1 })
> db.student.find()
{ "_id" : 1, "sname" : "lisi", "sage" : 22 }
{ "_id" : 2, "sname" : "zhangsan", "sage" : 25 }
>?
#修改數(shù)據(jù)
> db.student.update({_id:2},{$set:{sage:88}},false,true)
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.student.find().pretty()
{ "_id" : 1, "sname" : "lisi", "sage" : 22 }
{ "_id" : 2, "sname" : "zhangsan", "sage" : 88 }
#刪除數(shù)據(jù)
> db.student.remove({sname:'lisi'})
WriteResult({ "nRemoved" : 1 })
#刪除集合
> db.student.drop()
> show collections
teacher
> exit? #退出MongoDB Shell模式
bye
網(wǎng)頁(yè)題目:典型NoSQL數(shù)據(jù)庫(kù)的安裝和使用——MongoDB安裝和使用
本文URL:http://muchs.cn/article2/pichic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、電子商務(wù)、用戶體驗(yàn)、小程序開發(fā)、網(wǎng)站制作、移動(dòng)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)