1.Mongodb Installation in Ubuntu

(1) Download from: https://www.mongodb.org/downloads

File: mongodb-linux-x86_64-ubuntu1404-3.0.6.tgz

(2) Decompressing files.

  tar zxf mongodb-linux-x86_64-ubuntu1404-3.0.6.tgz

  mv mongodb-linux-x86_64-ubuntu1404-3.0.6 /usr/local/mongodb

(3) Create default directories for mongdb data files.

mkdir data

cd data

mkdir db

(4) Create default logs file.

  touch logs

(5) Run mongod.

--fork                      fork server process

--dbpath arg     directory for datafiles - defaults to /data/db

  --logpath arg     log file to send write to instead of stdout - has to be a file, not directory

  --httpinterface          enable http interface

  cd bin

  ./mongod --dbpath=/usr/local/mongodb/mongodb/data/db --fork --httpinterface --logpath=/usr/local/mongodb/mongodb/logs

(6) Check mongod process.

  ps -ef | grep mongo

(7) Check mongodb information.

  http://192.168.98.70:28017/

(8) Enter mongo shell.

  cd bin 

  ./mongo

MongoDB shell version: 3.0.6

connecting to: test

Welcome to the MongoDB shell.

For interactive help, type "help".

2.Use Mongodb.

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

3.CRUD.

  db.foo.insert({name:'edison',age:28})

  db.foo.insert({name:'scofield',age:30})

  db.foo.find()

  db.foo.find({name:'edison'})

  db.foo.update({name:'edison'},{name:'edison',age:40})

  db.foo.remove({age:40})

最新文章

  1. 如何设置ASP.NET页面的运行超时时间
  2. 阿里云服务器Linux CentOS安装配置(三)yum安装mysql
  3. HTML标记语法总结
  4. [转]c++类的构造函数详解
  5. Linux学习之六——使用vi和vim
  6. java语言基础02
  7. PowerMockito(PowerMock用法)
  8. Codevs 2597 团伙(并查集)
  9. statspack系列7
  10. 开源解析器--ANTLR
  11. 微软IE11浏览器的7大变化
  12. mysql导出数据表结构,必须退出mysql命令.重新使用msyqldump命令
  13. MySQL数据库使某个不是主键的字段唯一
  14. MySQL之记录相关操作
  15. 572. Subtree of Another Tree(easy)
  16. 修改oracle数据库允许连接的数
  17. SpringMVC(二八) 重定向
  18. UVA548-Tree(二叉树数组表示)
  19. this和引用变量的地址值是同一个---------new后面的是构造方法
  20. Html 助手

热门文章

  1. 第4章 jQuery中的事件和动画
  2. .net core 2.0 jwt身份认证系统
  3. 读取XML文档存入泛型List&lt;T&gt;集合中
  4. Bit(位) and Byte(字节) ASCll 编码【基础】
  5. C#中==与equal的区别
  6. Linux下的hosts文件和network文件区别
  7. 【Leetcode】Combinations
  8. Django 08 Django模型基础3(关系表的数据操作、表关联对象的访问、多表查询、聚合、分组、F、Q查询)
  9. 读经典——《CLR via C#》(Jeffrey Richter著) 笔记_方法执行
  10. 奇偶交错排列(DFS)