Ubuntu下MongoDB的安装和使用
本博文介绍了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默认设置MongoDB是随Ubuntu启动自动启动的。
输入命令,结果如下:
root@ubantu:/usr/src# service mongodb start
start: Job is already running: mongodb service mongodb stop
输入以下命令查看是否启动成功:
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的安装和使用的更多相关文章
- Ubuntu下MongoDB的安装
一.MongoDB介绍 MongoDB 是一个是一个基于分布式文件存储的数据库,介于关系数据库和非关系数据库之间,是非关系数据库当中功能最丰富,最像关系数据库的.他支持的数据结构非常松散,是类似jso ...
- [转] ubuntu 下mongodb的安装-----这篇文章也不错
在Ubuntu下进行MongoDB安装步骤 一. 在Ubuntu下最傻瓜的步骤(以下都在root用户下进行操作): 1.运行"apt-get install mongo" 如果遇到 ...
- 1. Ubuntu下MongoDB的安装和使用
一.MongoDB介绍 MongoDB 是一个是一个基于分布式文件存储的数据库,介于关系数据库和非关系数据库之间,是非关系数据库当中功能最丰富,最像关系数据库的.他支持的数据结构非常松散,是类似jso ...
- Ubuntu下git的安装与使用
Ubuntu下git的安装与使用 Ubuntu下git的安装与使用与Windows下的大致相同,只不过个人感觉在Ubuntu下使用git更方便. 首先,确认你的系统是否已安装git,可以通过git指令 ...
- Linux下MongoDB服务安装
Linux下MongoDB服务安装 MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案.MongoDB是一个介于关系数据库和非关系数据 ...
- Ubuntu下Speedtest的安装
要安装Speedtest,需要先安装apache,参见<Ubuntu下Apache的安装>一文:*(再安装LAMP server,参见<Ubuntu下快速安装LAMP server& ...
- Ubuntu下Apache的安装
Ubuntu下可快速安装LAMP server(Apache+MySQL+PHP5),参见<Ubuntu下快速安装LAMP server>一文. 也可以手动安装Apache.本文介绍如何手 ...
- Linux(Ubuntu)下MySQL的安装与配置
转自:http://www.2cto.com/database/201401/273423.html 在Linux下MySQL的安装,我一直觉得挺麻烦的,因为之前安装时就是由于复杂的配置导致有点晕.今 ...
- ubuntu下的openfire安装、配置、运行
openfire服务器 Openfire 采用Java开发,开源的实时协作(RTC)服务器基于XMPP(Jabber)协议.您可以使用它轻易的构建高效率的即时通信服务器.Op ...
随机推荐
- 'telnet' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
Win7或者win8等是默认没有安装telnet功能,所以你直接用telnet命令是用不了的: 下面介绍在win8下面如何操作:“控制面板”-->“程序”(在左下角)-->程序和功能--- ...
- Kafka查看偏移量报错:WARN WARNING: ConsumerOffsetChecker is deprecated and will be dropped in releases following 0.9.0. Use ConsumerGroupCommand instead.
Kafka0.9版本后,命令ConsumerOffsetChecker已弃用,用新的命令来查. // 列表 bin/kafka-consumer-groups.sh --zookeeper local ...
- 64位系统注冊32位的directshow filter文件
在SERVER2008上注冊自己写的directshow filter 的dll或者ax文件的时候总是提示 [Window Title] RegSvr32 [Content] 模块".\ba ...
- Unity iOS打开AppStore评星页面,浅谈Application.OpenURL()方法。
http://fairwoodgame.com/blog/?p=38 Unity iOS打开AppStore评星页面,浅谈Application.OpenURL()方法. Posted in Uni ...
- DirectShow控制台输出和保存视频设备名称
#include "windows.h" #include "TCHAR.h" #include <dshow.h> #include <ve ...
- 用.net installshield打包程序时注册第三方控件
制作打包程序时如果用到外部控件需要按以下方式操作: 1.将控件及控件所用到的所有DLL加入打包程序. 2.将控件的Register由vsdrfDoNotRegister改为vsdrfCOMSelfRe ...
- mvc模型绑定问题
public void AddDesk(x_s_desk x_s_desk) 绑定的到 public void AddDesk(x_s_desk desk) 绑定不到 目前不知道原因 且仅有部分模型需 ...
- ajax请求web容器控制超时
1.项目用到超时控制,针对ajax请求超时,可以参照如下解决方案 tomcat容器 web.xml 中配置 <session-config> <session-timeout> ...
- Scala 机器学习库
自然语言处理 ScalaNLP-机器学习和数值计算库的套装 Breeze -Scala用的数值处理库 Chalk-自然语言处理库. FACTORIE-可部署的概率建模工具包.用Scala实现的软件库. ...
- springboot学习(五) 全局异常处理
创建全局异常处理 /** * 全局异常配置管理 */ @ControllerAdvice public class GlobalExceptionConfig extends ResponseEnti ...