图解Mongo Shell的使用
mongo shell是一个MongoDB的交互式JavaScript接口。您可以使用mongo shell来查询和更新数据以及执行管理操作。
本篇经验将和大家介绍Mongo Shell的使用方法,希望对大家的工作和学习有所帮助!
方法/步骤
打开cmd命令行,输入mongo,就可以进入mongo Shell,如下图所示:

输入cls命令清屏,开始常用命令体验,如下图所示:

show dbs
输入show dbs,显示当前所有数据库,这里显示了默认的数据库,如下图所示:

use 数据库名
这个命令可以切换到指定的数据库,如果切换到了不存在的数据库,当在这个数据库存储数据时,就会自动创建这个数据库。
我们输入show school,切换到school数据库,这里返回了switched to db school,如下图所示:

show collections
这个命令可以显示当前数据库下的所有集合,我们输入show collections试一下,可以发现,students数据库下什么集合都没有,如下图所示:

db.collection.insert()
这个方法把文档插入到集合中,我们输入db.student.insert({name:"hushiyun",age:24}),将一条数据(文档)插入。这里返回的结果显示已经插入了一条文档,如下图所示:

db.collection.find()
这个方法可以查询当前集合中所有的文档,我们输入进去查询一下,这样就查到了我们刚才插入的那一条文档,如下图所示:

图解Mongo Shell的使用的更多相关文章
- MongoDB error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js(转)
rror: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js 一般这种情况就是:自己指定的数据库,所以不能.自动加 ...
- 常见的mongo shell命令
启动mongo shell 在windows下,双击mongo.exe可以启动mongo shell 查询库.表及选择库 查询所有库命令: show dbs 应用某一个db use jxs_datab ...
- MongoDB - The mongo Shell, mongo Shell Quick Reference
mongo Shell Command History You can retrieve previous commands issued in the mongo shell with the up ...
- MongoDB - The mongo Shell, Data Types in the mongo Shell
MongoDB BSON provides support for additional data types than JSON. Drivers provide native support fo ...
- MongoDB - The mongo Shell, Write Scripts for the mongo Shell
You can write scripts for the mongo shell in JavaScript that manipulate data in MongoDB or perform a ...
- MongoDB - The mongo Shell, Access the mongo Shell Help
In addition to the documentation in the MongoDB Manual, the mongo shell provides some additional inf ...
- MongoDB - The mongo Shell, Configure the mongo Shell
Customize the Prompt You may modify the content of the prompt by setting the variable prompt in the ...
- MongoDB - Introduction of the mongo Shell
Introduction The mongo shell is an interactive JavaScript interface to MongoDB. You can use the mong ...
- couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
当直接执行./mongo 出现这样的提示:couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145 解决: ...
随机推荐
- EDU 50 E. Covered Points 利用克莱姆法则计算线段交点
E. Covered Points 利用克莱姆法则计算线段交点.n^2枚举,最后把个数开方,从ans中减去. ans加上每个线段的定点数, 定点数用gcs(△x , △y)+1计算. #include ...
- POJ - 3436 ACM Computer Factory 网络流
POJ-3436:http://poj.org/problem?id=3436 题意 组配计算机,每个机器的能力为x,只能处理一定条件的计算机,能输出特定的计算机配置.进去的要求有1,进来的计算机这个 ...
- 洛谷P1196[NOI2002]银河英雄传说-并查集扩展
银河英雄传说 题意:在并查集的基础上,还要求出同一集合的两个点的距离 这道题用并查集自己是知道的,但是竟然可以这么骚的操作. 下面转自大佬的查详细题解 初见这道题,首先想到的方法当然是直接模拟,模拟每 ...
- HDU2276 Kiki & Little Kiki 2 矩阵快速幂
Kiki & Little Kiki 2 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java ...
- CF990B Micro-World 贪心 第十六
Micro-World time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...
- hdu 1671 Phone List 字典树模板
Given a list of phone numbers, determine if it is consistent in the sense that no number is the pref ...
- ubantu下配置共享文件
原文转自 http://blog.chinaunix.net/uid-25305993-id-3754109.html 一 samba的安装: sudo apt-get install samba ...
- 用PhpStrom线上连接修改linux服务器上代码配置
为了进一步提高自己的技能水平,不久前入手了一台服务器,不贵,一年也就不到两百,因为自己对于linux机器比较生疏,命令用的有点抠脚.老需要查阅处理. 于是我选择用PhpStrom直接连接线上服务器,通 ...
- Vue组件间通信方式
一.Props传递数据 在父组件中使用子组件,本质通过v-bind绑定属性传入子组件,子组件通过props接收父组件传入的属性 <template> <div> 父组件:{{m ...
- [币严区块链]数字货币交易所之瑞波(XRP)钱包对接
对接Ripple(XRP),不需要本地部署钱包,直接访问Ripple API,本文包括访问Ripple API及如何免费获取测试的XRP. 对接流程 安装Ripple API Ripple API 接 ...