图解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 解决: ...
随机推荐
- 【selenium】- webdriver常见api
本文由小编根据慕课网视频亲自整理,转载请注明出处和作者. 1.常见API 2.打开网址 3.操作浏览器 quit()没有完全关闭进程,依旧占用资源. 4.输入框操作 5.选择框操作 6.特殊窗口操作 ...
- Linux之acl库的安装与使用(限制Linux某用户的访问权限)
acl库 作用:限制Linux某用户的访问权限 acl库的安装 首先github中下载acl代码: git clone https://github.com/acl-dev/acl 进入acl, 执行 ...
- 【MySQL】为什么SQL会这么慢
建表 CREATE TABLE `ts_ab` ( `id` int(11) NOT NULL, `a` int(11) DEFAULT NULL, `b` varchar(20) CHARACTER ...
- RHEL7破解密码操作步骤
首先查看系统是什么版本 cat /etc/redhat-release 第1步:然后重启Linux系统并出现引导界面时,按下键盘上的e键进入内核编辑界面. 第2步:在Linux16 参数这行的最后面追 ...
- 剑指Offer(三十二):把数组排成最小的数
剑指Offer(三十二):把数组排成最小的数 搜索微信公众号:'AI-ming3526'或者'计算机视觉这件小事' 获取更多算法.机器学习干货 csdn:https://blog.csdn.net/b ...
- 机器学习——支持向量机(SVM)
支持向量机原理 支持向量机要解决的问题其实就是寻求最优分类边界.且最大化支持向量间距,用直线或者平面,分隔分隔超平面. 基于核函数的升维变换 通过名为核函数的特征变换,增加新的特征,使得低维度空间中的 ...
- 2018阿里-研发工程师JAVA Software Engineer, Java
岗位描述Job Description如果你想了解JAVA开发在阿里巴巴互联网生态系统中无与伦比的应用广度与深度: 如果你对基础技术感兴趣,你可以参与基础软件的设计.开发和维护,如分布式文件系统.缓存 ...
- 实验吧CTF练习题---WEB---Forms解析
实验吧web之Forms 地址:http://www.shiyanbar.com/ctf/1819 flag值:ctf{forms_are_easy} 解题步骤: 1.查看页面源代码,从中发现&q ...
- pageable多字段排序问题
Sort sort = new Sort(Sort.Direction.DESC, "createdate") .and(new Sort(Sort.Direction.AES, ...
- JSP获取网络IP地址
import javax.servlet.http.HttpServletRequest; public class RemoteAddress { public static String getR ...