MongoDB命令帮助系统
在安装MongoDB后,启动服务器进程(mongod),可以通过在客户端命令mongo实现对MongoDB的管理和监控。看一下MongoDB的命令帮助系统:
root@dev2:~# mongo MongoDB shell version: 1.8.3 connecting to: test > help db.help() help on db methods db.mycoll.help() help on collection methods rs.help() help on replica set methods help connect connecting to a db help help admin administrative help help misc misc things to know help mr mapreduce help show dbs show database names show collections show collections in current database show users show users in current database show profile show most recent system.profile entries with time >= 1ms use <db_name> set current database db.foo.find() list objects in collection foo db.foo.find( { a : 1 } ) list objects in foo where a == 1 it result of the last line evaluated; use to further iterate DBQuery.shellBatchSize = x set default number of items to display on shell exit quit the mongo shell
这是MongoDB最顶层的命令列表,主要告诉我们管理数据库相关的一些抽象的范畴:数据库操作帮助、集合操作帮助、管理帮助。如果你想了解数据库操作更详细的帮助命令,可以直接使用db.help(),如下所示:
> db.help() DB methods: db.addUser(username, password[, readOnly=false]) db.auth(username, password) db.cloneDatabase(fromhost) db.commandHelp(name) returns the help for the command db.copyDatabase(fromdb, todb, fromhost) db.createCollection(name, { size : ..., capped : ..., max : ... } ) db.currentOp() displays the current operation in the db db.dropDatabase() db.eval(func, args) run code server-side db.getCollection(cname) same as db['cname'] or db.cname db.getCollectionNames() db.getLastError() - just returns the err msg string db.getLastErrorObj() - return full status object db.getMongo() get the server connection object db.getMongo().setSlaveOk() allow this connection to read from the nonmaster member of a replica pair db.getName() db.getPrevError() db.getProfilingLevel() - deprecated db.getProfilingStatus() - returns if profiling is on and slow threshold db.getReplicationInfo() db.getSiblingDB(name) get the db at the same server as this one db.isMaster() check replica primary status db.killOp(opid) kills the current operation in the db db.listCommands() lists all the db commands db.printCollectionStats() db.printReplicationInfo() db.printSlaveReplicationInfo() db.printShardingStatus() db.removeUser(username) db.repairDatabase() db.resetError() db.runCommand(cmdObj) run a database command. if cmdObj is a string, turns it into { cmdObj : 1 } db.serverStatus() db.setProfilingLevel(level,<slowms>) 0=off 1=slow 2=all db.shutdownServer() db.stats() db.version() current version of the server db.getMongo().setSlaveOk() allow queries on a replication slave server
对数据库进行管理和操作的基本命令,可以从上面获取到。如果想要得到更多,而且每个命令的详细用法,可以使用上面列出的db.listCommands()查询。
另一个比较基础的是对指定数据库的集合进行操作、管理和监控,可以通过查询db.mycoll.help()获取到:
> db.mycoll.help() DBCollection help db.mycoll.find().help() - show DBCursor help db.mycoll.count() db.mycoll.dataSize() db.mycoll.distinct( key ) - eg. db.mycoll.distinct( 'x' ) db.mycoll.drop() drop the collection db.mycoll.dropIndex(name) db.mycoll.dropIndexes() db.mycoll.ensureIndex(keypattern[,options]) - options is an object with these possible fields: name, unique, dropDups db.mycoll.reIndex() db.mycoll.find([query],[fields]) - query is an optional query filter. fields is optional set of fields to return. e.g. db.mycoll.find( {x:77} , {name:1, x:1} ) db.mycoll.find(...).count() db.mycoll.find(...).limit(n) db.mycoll.find(...).skip(n) db.mycoll.find(...).sort(...) db.mycoll.findOne([query]) db.mycoll.findAndModify( { update : ... , remove : bool [, query: {}, sort: {}, 'new': false] } ) db.mycoll.getDB() get DB object associated with collection db.mycoll.getIndexes() db.mycoll.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } ) db.mycoll.mapReduce( mapFunction , reduceFunction , <optional params> ) db.mycoll.remove(query) db.mycoll.renameCollection( newName , <dropTarget> ) renames the collection. db.mycoll.runCommand( name , <options> ) runs a db command with the given name where the first param is the collection name db.mycoll.save(obj) db.mycoll.stats() db.mycoll.storageSize() - includes free space allocated to this collection db.mycoll.totalIndexSize() - size in bytes of all the indexes db.mycoll.totalSize() - storage allocated for all data and indexes db.mycoll.update(query, object[, upsert_bool, multi_bool]) db.mycoll.validate() - SLOW db.mycoll.getShardVersion() - only for use with sharding
有关数据库和集合管理的相关命令,是最基础和最常用的,如集合查询、索引操作等。
相关推荐
MongoDB命令帮助系统 在安装MongoDB后,启动服务器进程(mongod),可以通过在客户端命令mongo实现对MongoDB的管理和监控。看一下MongoDB的命令帮助系统: root@dev:~# mongo MongoDB she
在安装过程中,本文详细列出了每一个步骤,并附带了相关的命令和参数解释,帮助读者理解每一步操作的意义。同时,针对可能出现的常见问题,本文也提供了相应的解决方案,帮助用户顺利解决安装过程中的疑难问题。 ...
本书旨在帮助云计算初学者迅速掌握MongoDB数据库,提升读者在云计算实践中的应用和开发能力。同时本书极强的系统性和大量翔实的案例对于有一定基础的中高级用户有非常好的参考价值。 第1篇 基础篇 第1章 MongoDB...
本书旨在帮助云计算初学者迅速掌握MongoDB数据库,提升读者在云计算实践中的应用和开发能力。同时本书极强的系统性和大量翔实的案例对于有一定基础的中高级用户有非常好的参考价值。 第1篇 基础篇 第1章 MongoDB...
isodata的matlab代码博客笔记MongoDB 介绍 MongoDB 不强制执行任何模式,因此文档不必在一个集合内使用相同的模式。 ...上面这个命令将mongod进程作为子进程启动并在后台运行。 要停止这个 mongoDB
本文讲解了mongodb的replica模式的搭建方法,集群的搭建方法,以及常用的增删改查命令、系统资源的监控命令,以及一些配置参数代表的意思,为你自己使用搭建mongo的复制集群使用提供帮助,并配有实际的搭建步骤,...
总之,基于小程序的教师预订系统是一款功能丰富、易于使用的应用程序,能够帮助学校提高教师预订效率,提升教学质量。如果您需要进行教师预订或课程表管理方面的工作,那么该小程序将会是一个非常不错的选择。
接着,可以通过npm命令进行项目打包,然后将生成的文件上传到服务器即可。需要注意的是,由于该应用程序采用了前后端分离的开发模式,因此需要分别部署前端和后端两个部分。 在使用该应用程序时,用户可以根据自己...
同时,为了保证系统的安全性,还采用了JWT token进行用户认证和授权。 部署该应用程序需要先安装Node.js环境和MongoDB数据库,并在本地创建相应的数据库。接着,可以通过npm命令进行项目打包,然后将生成的文件上传...
同时,为了保证系统的安全性,还采用了JWT token进行用户认证和授权。 部署该小程序需要先安装Node.js环境和MongoDB数据库,并在本地创建相应的数据库。接着,可以通过npm命令进行项目打包,然后将生成的文件上传到...
Katpard是一套前端页面性能检测系统,这套系统是为了帮助前端开发人员能够快速准确的了解页面性能状况 适用场景 日常的性能预警 页面性能对比 Requirements Katpard 依赖 和 来存取数据,因此在使用本系统前请务必...
该应用程序是使用JHipster 4.14.4生成的,您可以在找到文档和帮助。 发展 在生成此项目之前,必须在计算机上安装和配置以下依赖项: :我们使用Node来运行开发Web服务器并构建项目。 根据您的系统,可以从源安装或...
诊所管理系统这是一个用于管理诊所预约的应用程序。克隆我的仓库 git clone https://github.com/muhammadsemeer/clinic-management-system克隆后,通过键入以下命令转到目录。 cd clinic-management-system然后,...
构建InfoCinemas的信息系统使用Flask,MongoDB和Docker技术。 更具体地说,它基于一对容器,其中包括数据库和Web应用程序。 数据库 MongoDB数据库遵循以下结构: InfoCinemas数据库包含两个“用户/电影”(集合)...
HomeLife家居生活网站1.说明:使用react框架搭建的一个家居生活网站,麻雀虽小,五脏俱全,...#开启MongoDB服务:Mac系统在终端输入:sudo mongod命令,输入电脑密码即可开启服务。(Windows系统不再介绍)#进入后
Lepus提供数据库的基础数据指标采集,比如数据库版本,运行时间,基本健康状态,核心配置参数等基础数据,有了这些基础数据,无需登录机器即可通过系统集中查询,减少了DBA运维人员的重复性工作和枯燥的敲命令工作。...
或使用以下命令克隆Github库: $ git clone https://github.com/Guetop/uam-c-gestion.git导航到该文件夹并运行以下命令以安装所有依赖项: $ npm install运行Node.js(确保您正在运行MongoDB) $ node server....
MongoDB -并安装 mongodb - 如果您刚刚开始,请。 Node.js -并安装 Node.js,nodeschool 提供免费的节点教程来帮助您入门。 Git - 使用包管理器获取 git 或它。 Grunt - 下载并安装 。 $ npm install -g grunt-...
您将需要在系统中安装npm CLI 将CD放入项目cd HackOverFlow 4.0 安装所有依赖项npm install 将app.js上的mongoDB URI替换为您的数据库链接 或者,运行以下命令以运行本地mongo服务器mongod 在localhost npm ...
大型项目设置所有系统的设置都应该很容易,因为它只需要安装 NodeJS 和 MongoDB。 为您的系统下载并安装 。 为您的系统下载并安装 。 您还可以获得 ,这将有助于手动配置数据库。 使用特权运行此命令。 视窗: 以...