征服 Mongodb 之 常用命令、基本数据类型

手里有本《MongoDB权威指南》,打算做个读书笔记,把常规命令、数据类型过一遍,强迫记忆。酷

相关文章:

征服 Mongodb 之 安装与主从配置

关于如何安装、配置、启动MongoDB等,参考上篇文章。

一、常规命令

  • 登录

类似于MySQL登录,可参考如下命令:

Shell代码 复制代码 收藏代码
  1. # mongo --help
  2. MongoDB shell version: 2.0.7
  3. usage: mongo [options] [db address] [file names (ending in .js)]
  4. db address can be:
  5. foo foo database on local machine
  6. 192.169.0.5/foo foo database on 192.168.0.5 machine
  7. 192.169.0.5:9999/foo foo database on 192.168.0.5 machine on port 9999
  8. options:
  9. --shell run the shell after executing files
  10. --nodb don't connect to mongod on startup - no 'db address' arg expected
  11. --norc will not run the ".mongorc.js" file on start up
  12. --quiet be less chatty
  13. --port arg port to connect to
  14. --host arg server to connect to
  15. --eval arg evaluate javascript
  16. -u [ --username ] arg username for authentication
  17. -p [ --password ] arg password for authentication
  18. -h [ --help ] show this usage information
  19. --version show version information
  20. --verbose increase verbosity
  21. --ipv6 enable IPv6 support (disabled by default)
  22. file names: a list of files to run. files have to end in .js and will exit after unless --shell is specified

譬如,我经常这么用,一步到位:

Shell代码 复制代码 收藏代码
  1. # mongo 10.11.20.140/zlex
  2. MongoDB shell version: 2.0.7
  3. connecting to: 10.11.20.140/zlex
  4. >

posted on 2013-02-06 16:40  蜜雪薇琪  阅读(320)  评论(0编辑  收藏  举报