图解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 解决: ...
随机推荐
- Fiddle用于移动端抓包
一.什么情况下可以用到 1.调查参考其他移动端网站的抓包,他们传输方式.如微信上京东的智能机器人的包.移动端的请求接口格式.如何实现的效果等. 2.调试本地移动端页面的测试页面效果是否有问题.如:页面 ...
- I-Just Jump_2019牛客暑期多校训练营(第八场)
题目链接 Just Jump 题意 有L+1个点,初始在第0个点上,要跳到第L个点,每次至少跳d格,也就是在点x至少要跳到x+d,且有m个限制 \((t_i, p_i)\)指跳第\(t_i\)次不能跳 ...
- STL中set和multiset小结
(1)使用set/multiset之前必须包含头文件<set>:#include<set> (2)namespace std{ template <cla ...
- lightoj 1105 - Fi Binary Number(dp+思维(斐波那契))
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1105 题解:这题你会巧妙的发现 1-(1),2-(10),3-(100),5- ...
- Codeforces 416D Population Size
Population Size 题意: 一共n个数, 每个-1都可以变成一个正数, 现在要求最少数目的等差子序列,并且在这个子序列必须要连着截取一段,不能分开截取. 样例1: 8 6 4 2 1 4 ...
- poj 2912 Rochambeau(枚举+带权并查集)
题目链接:http://poj.org/problem?id=2912 题意:多个人玩石头剪刀布分成3组和一个裁判,每一组提前选定了自己出哪个手势,裁判可以随意出什么手势,问是否能够从给出的一系列石头 ...
- HDU 1010 temp of the bone 解题报告 (DFS)
转载大佬的blog,很详细,学到了很多东西 奇偶剪枝:根据题目,dog必须在第t秒到达门口.也就是需要走t-1步.设dog开始的位置为(sx,sy),目标位置为(ex,ey).如果abs(ex-x)+ ...
- 手把手告诉你如何安装多个版本的node,妈妈再也不用担心版本高低引发的一系列后遗症(非常详细,非常实用)
简介 最近好多人都问到node怎么同时安装多个版本? 如何配置node的环境变量,如何自如的在多个版本中切换node?还有就是自己在做appium自动化的时候,有时候会因为node的版本过高或者是太低 ...
- Android集成JPush极光推送
推送原理 参考网址:https://blog.csdn.net/huangli1466384630/article/details/79889473 SDK下载 https://docs.jiguan ...
- HTML5为什么只需要写<!DOCTYPE HTML>?
HTML4.01中的doctype需要对DTD进行引用,因为HTML4.01基于SGML.而HTML5不基于SGML,因此不需要对DTD进行引用,但是需要doctype来规范浏览器的行为.其中,SGM ...