佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > MongoDB最基本命令速查筆記

MongoDB最基本命令速查筆記

熱門標(biāo)簽:鐵路電話系統(tǒng) 網(wǎng)站排名優(yōu)化 Linux服務(wù)器 服務(wù)外包 呼叫中心市場(chǎng)需求 百度競(jìng)價(jià)排名 地方門戶網(wǎng)站 AI電銷

安裝后在控制臺(tái)輸入:

mongo啟動(dòng)客戶端。

show dbs顯示所有數(shù)據(jù)庫(kù)。

use xxx選中數(shù)據(jù)庫(kù)為當(dāng)前使用的數(shù)據(jù)庫(kù)。

show collections顯示當(dāng)前數(shù)據(jù)庫(kù)的所有集合。

db.colleciton.find()來(lái)查找表格的所有數(shù)據(jù)。

db.serverStatus()查看數(shù)據(jù)庫(kù)服務(wù)器的狀態(tài)。

db.stats()查詢指定數(shù)據(jù)庫(kù)的統(tǒng)計(jì)信息。

use xxx如果數(shù)據(jù)庫(kù)不存在則創(chuàng)建數(shù)據(jù)庫(kù)(必須在雖然插入一條數(shù)據(jù))

db.storeCollection.insert({'version':'13', 'segment':'456'})插入數(shù)據(jù),同時(shí)創(chuàng)建集合

db.dropDatabase()刪除數(shù)據(jù)庫(kù)

db.mycoll.drop()刪除集合

db.storeCollection.save({'version':'3.5', 'segment':'e3ol6'})更新記錄

db.storeCollection.remove({'version':'3.5'}) 刪除記錄

db.page.ensureIndex({'title':1, 'url':-1})創(chuàng)建索引,1正序,-1逆序

db.page.getIndexes()查詢建立的索引

db.mycoll.dropIndex(name) 刪除索引,如果不帶參數(shù),刪除所有索引

db.baseSe.reIndex()重建索引

db.baseSe.storageSize()查詢指定數(shù)據(jù)庫(kù)的集合的可用的存儲(chǔ)空間

db.baseSe.totalSize()查詢集合已分配的存儲(chǔ)空間

PS:非正常關(guān)閉后無(wú)法啟動(dòng)問題
段時(shí)間不小心非正常關(guān)閉了mongoDB,準(zhǔn)備重啟卻發(fā)現(xiàn)不行,錯(cuò)誤信息如下:

Tue Apr 17 11:13:30
Tue Apr 17 11:13:30 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Tue Apr 17 11:13:30
Tue Apr 17 11:13:30 [initandlisten] MongoDB starting : pid=7128 port=27017 dbpath=D:\Programs\mongodb204\db 32-bit host=FALCON
Tue Apr 17 11:13:30 [initandlisten]
Tue Apr 17 11:13:30 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Tue Apr 17 11:13:30 [initandlisten] **    see http://blog.mongodb.org/post/137788967/32-bit-limitations
Tue Apr 17 11:13:30 [initandlisten] **    with --journal, the limit is lower
Tue Apr 17 11:13:30 [initandlisten]
Tue Apr 17 11:13:30 [initandlisten] db version v2.0.4, pdfile version 4.5
Tue Apr 17 11:13:30 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506cb21f8ebf
Tue Apr 17 11:13:30 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=0, build=6002, platform=2, service_pack='Service Pack 2')BOOST_LIB_VERSION=1_42
Tue Apr 17 11:13:30 [initandlisten] options: { dbpath: "D:\Programs\mongodb204\db" }
**************
Unclean shutdown detected.
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
*************
Tue Apr 17 11:13:30 [initandlisten] exception in initAndListen: 12596 old lock file, terminating
Tue Apr 17 11:13:30 dbexit:
Tue Apr 17 11:13:30 [initandlisten] shutdown: going to close listening sockets...
Tue Apr 17 11:13:30 [initandlisten] shutdown: going to flush diaglog...
Tue Apr 17 11:13:30 [initandlisten] shutdown: going to close sockets...
Tue Apr 17 11:13:30 [initandlisten] shutdown: waiting for fs preallocator...
Tue Apr 17 11:13:30 [initandlisten] shutdown: closing all files...
Tue Apr 17 11:13:30 [initandlisten] closeAllFiles() finished
Tue Apr 17 11:13:30 dbexit: really exiting now

解決方法:
1、刪除%MONGO_HOME%/db下的.lock文件

2、輸入命令 mongod --repair

3、重啟mongoDB

您可能感興趣的文章:
  • MongoDB常用操作命令大全
  • mongodb與mysql命令詳細(xì)對(duì)比
  • MongoDB常用命令小結(jié)
  • Ubuntu系統(tǒng)中安裝MongoDB及其啟動(dòng)命令mongod的教程
  • MongoDB入門教程(包含安裝、常用命令、相關(guān)概念、使用技巧、常見操作等)
  • MongoDB使用mongoexport和mongoimport命令,批量導(dǎo)出和導(dǎo)入JSON數(shù)據(jù)到同一張表的實(shí)例
  • Mongodb啟動(dòng)命令參數(shù)中文說(shuō)明
  • mongodb數(shù)據(jù)庫(kù)的6個(gè)安全設(shè)置命令
  • mongodb 命令行下及php中insert數(shù)據(jù)詳解
  • 詳解MongoDB管理命令
  • Ubuntu下安裝PHP的mongodb擴(kuò)展操作命令
  • MongoDB中的主從同步配置和mongod相關(guān)啟動(dòng)命令講解
  • MongoDB使用自帶的命令行工具進(jìn)行備份和恢復(fù)的教程
  • MongoDB Shell 命令實(shí)例總結(jié)【進(jìn)階篇】
  • Mongodb 啟動(dòng)命令mongod參數(shù)說(shuō)明(中文翻譯)
  • mongodb監(jiān)控工具mongostat的使用及命令詳解
  • MongoDB的基本安裝與管理命令腳本總結(jié)
  • MongoDB常用數(shù)據(jù)庫(kù)命令大全

標(biāo)簽:銅川 蘭州 黃山 湖南 衡水 湘潭 崇左 仙桃

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《MongoDB最基本命令速查筆記》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    永寿县| 娱乐| 绥化市| 光山县| 通山县| 岗巴县| 万州区| 乌拉特前旗| 萍乡市| 汪清县| 犍为县| 晋中市| 芦溪县| 普安县| 东海县| 大安市| 遂溪县| 台中市| 山东省| 郑州市| 汕头市| 都江堰市| 涿鹿县| 乌审旗| 江源县| 徐汇区| 四平市| 灯塔市| 伽师县| 凉城县| 银川市| 崇州市| 金坛市| 抚宁县| 剑阁县| 霸州市| 宁都县| 陇川县| 甘孜| 嘉义市| 广平县|