安装后在控制台输入:
mongo启动客户端。
show dbs显示所有数据库。
use xxx选中数据库为当前使用的数据库。
show collections显示当前数据库的所有集合。
db.colleciton.find()来查找表格的所有数据。
db.serverStatus()查看数据库服务器的状态。
db.stats()查询指定数据库的统计信息。
use xxx如果数据库不存在则创建数据库(必须在虽然插入一条数据)
db.storeCollection.insert({'version':'13', 'segment':'456'})插入数据,同时创建集合
db.dropDatabase()删除数据库
db.mycoll.drop()删除集合
db.storeCollection.save({'version':'3.5', 'segment':'e3ol6'})更新记录
db.storeCollection.remove({'version':'3.5'}) 删除记录
db.page.ensureIndex({'title':1, 'url':-1})创建索引,1正序,-1逆序
db.page.getIndexes()查询建立的索引
db.mycoll.dropIndex(name) 删除索引,如果不带参数,删除所有索引
db.baseSe.reIndex()重建索引
db.baseSe.storageSize()查询指定数据库的集合的可用的存储空间
db.baseSe.totalSize()查询集合已分配的存储空间
PS:非正常关闭后无法启动问题
段时间不小心非正常关闭了mongoDB,准备重启却发现不行,错误信息如下:
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
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- RonaldBrautigam,PeterMasseursandConcertgebouwOrchestraAmsterdam-ShostakovichTheJazz
- 筷子兄弟《老男孩》[WAV+CUE][899M]
- 陈曦《寂寞在唱歌HQCD》2023头版限量编号[WAV+CUE][1G]
- 张惠妹《阿密特》NEW XRCD[WAV+CUE][455M]
- 邓伟标《西游记之悟空》24K金碟限量编号首版[低速原抓WAV+CUE]
- 群星《2024好听新歌40》AI调整音效【WAV分轨】
- 张梦弘《大城小爱HQ》头版限量编号[低速原抓WAV+CUE]
- 张敬轩《MY 1ST COLLECTION》2CD[WAV+CUE][1.7G]
- 张玮伽《夜归人HQⅡ》2024头版限量编号[WAV+CUE][523M]
- 证声音乐图书馆《夏至 爵士境地》[320K/MP3][70.37MB]
- 孙露《同名专辑》限量1:1母盘直刻[低速原抓WAV+CUE]
- 【宝丽金唱片】群星《鼓舞飞扬》WAV+CUE
- 莫扎特弗雷德沃夏克肖斯塔科维奇《钢琴五重奏》(DG24-96)FLAC
- 证声音乐图书馆《夏至 爵士境地》[FLAC/分轨][360.16MB]
- 证声音乐图书馆《日落琴声 x 弦乐》[320K/MP3][71.2MB]