本博文介绍了MongoDB,并详细指引读者在Ubuntu下MongoDB的安装和使用。本教程在Ubuntu14.04下测试通过.(2017.09.07)

安装MongoDB

MongoDB安装很简单,无需下载源文件,可以直接用apt-get命令进行安装。
打开终端,输入以下命令:

sudo apt-get install mongodb

安装完成后,在终端输入以下命令查看MongoDB版本:
mongo -version

输出版本信息,表明安装成功,如下:

root@ubantu:/usr/src# mongo -version
MongoDB shell version: 2.4.9 启动和关闭mongodb命令如下:
service mongodb start
输入命令,结果如下:
root@ubantu:/usr/src# service mongodb start
start: Job is already running: mongodb service mongodb stop
默认设置MongoDB是随Ubuntu启动自动启动的。
输入以下命令查看是否启动成功:
pgrep mongo -l   #注意:-l是英文字母l,不是阿拉伯数字1

卸载MongoDB
sudo apt-get --purge remove mongodb mongodb-clients mongodb-server

使用MongoDB

shell命令模式

输入mongo进入shell命令模式,默认连接的数据库是test数据库,在此之前一定要确保你已经启动了MongoDB,否则会出现错误,启动之后运行成功,如下图:

root@ubantu:/usr/src# mongo
MongoDB shell version: 2.4.9
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
    http://docs.mongodb.org/
Questions? Try the support group
    http://groups.google.com/group/mongodb-user
>
常用操作命令:

db.help()                    help on db methods
    db.mycoll.help()             help on collection methods
    sh.help()                    sharding helpers
    rs.help()                    replica set helpers
    help admin                   administrative help
    help connect                 connecting to a db help
    help keys                    key shortcuts
    help misc                    misc things to know
    help mr                      mapreduce

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
    show logs                    show the accessible logger names
    show log [name]              prints out the last segment of log in memory, 'global' is default
    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

Ubuntu下MongoDB的安装和使用的更多相关文章

  1. Ubuntu下MongoDB的安装

    一.MongoDB介绍 MongoDB 是一个是一个基于分布式文件存储的数据库,介于关系数据库和非关系数据库之间,是非关系数据库当中功能最丰富,最像关系数据库的.他支持的数据结构非常松散,是类似jso ...

  2. [转] ubuntu 下mongodb的安装-----这篇文章也不错

    在Ubuntu下进行MongoDB安装步骤 一. 在Ubuntu下最傻瓜的步骤(以下都在root用户下进行操作): 1.运行"apt-get install mongo" 如果遇到 ...

  3. 1. Ubuntu下MongoDB的安装和使用

    一.MongoDB介绍 MongoDB 是一个是一个基于分布式文件存储的数据库,介于关系数据库和非关系数据库之间,是非关系数据库当中功能最丰富,最像关系数据库的.他支持的数据结构非常松散,是类似jso ...

  4. Ubuntu下git的安装与使用

    Ubuntu下git的安装与使用 Ubuntu下git的安装与使用与Windows下的大致相同,只不过个人感觉在Ubuntu下使用git更方便. 首先,确认你的系统是否已安装git,可以通过git指令 ...

  5. Linux下MongoDB服务安装

    Linux下MongoDB服务安装 MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案.MongoDB是一个介于关系数据库和非关系数据 ...

  6. Ubuntu下Speedtest的安装

    要安装Speedtest,需要先安装apache,参见<Ubuntu下Apache的安装>一文:*(再安装LAMP server,参见<Ubuntu下快速安装LAMP server& ...

  7. Ubuntu下Apache的安装

    Ubuntu下可快速安装LAMP server(Apache+MySQL+PHP5),参见<Ubuntu下快速安装LAMP server>一文. 也可以手动安装Apache.本文介绍如何手 ...

  8. Linux(Ubuntu)下MySQL的安装与配置

    转自:http://www.2cto.com/database/201401/273423.html 在Linux下MySQL的安装,我一直觉得挺麻烦的,因为之前安装时就是由于复杂的配置导致有点晕.今 ...

  9. ubuntu下的openfire安装、配置、运行

    openfire服务器              Openfire 采用Java开发,开源的实时协作(RTC)服务器基于XMPP(Jabber)协议.您可以使用它轻易的构建高效率的即时通信服务器.Op ...

随机推荐

  1. 关于group by后为每个分组编号

  2. 一起來玩鳥 Starling Framework(4)TouchEvent,Touch,以及TouchPhase

    這一篇來介紹一下TouchEvent.我們先來談單點的touch,下一篇再介紹MultiTouch.翻過Starling文件的應該會發現,Starling裡面沒有MouseEvent,而是整合在Tou ...

  3. Directive Controller And Link Timing In AngularJS

    I've talked about the timing of directives in AngularJS a few times before. But, it's a rather compl ...

  4. Tomcat:IOException while loading persisted sessions: java.io.EOFException 解决

    转自:http://www.blogjava.net/apple0668/archive/2007/10/12/152383.html Tomcat启动时如下错误: 严重: IOException w ...

  5. docker实战——构建Jekyll

    构建第一个应用 要构建的第一个应用是Jekyll框架的自定义网站.我们会构建一下两个镜像. 一个镜像安装Jekyll以及其他用于构建Jekyll网站的必要的软件包. 一个镜像通过Apache来让Jek ...

  6. 让Qt Creator支持Windows Phone 8开发

    让Qt Creator支持Windows Phone 8开发 近期QtCreator3.2出了.修复了一些Bug.比上一个版本号3.1.2要好了一些. 因为在上一个版本号(Qt for WinRT自带 ...

  7. C#秘密武器之反射——基础篇

    先来一段有用的反射代码 namespace Calculator { public interface Iwel { String Print(); } } namespace Calculator ...

  8. [翻译]JUnit 5 用户手册

    为了系统的学习下 JUnit 5, 因此开始翻译 JUnit 5 官方用户手册, 谢谢关注! 本手册翻译自 5.0.0-M4 版本. 若感兴趣, 可 star 或 fork 该仓库! GitHub: ...

  9. apktool反编译工具使用详解

    文章转自: http://zhangyan1158.blog.51cto.com/2487362/683234 一.APKTOOL使用环境配置 1.安装JAVA并设置环境变量. 下载安装都很简单,关键 ...

  10. [WebView学习之三]:使用WebView来创建Apps

    上一篇我们学习了([WebView学习之二]:使用Web Apps 支持不同分辨率屏),今天我们来继续学习. (博客地址:http://blog.csdn.net/developer_jiangqq) ...