`
EdgenHuang
  • 浏览: 109468 次
  • 性别: Icon_minigender_1
  • 来自: 福建泉州
社区版块
存档分类
最新评论

MongoDB命令备忘

    博客分类:
  • DB
阅读更多


E:\>cd mongodb

E:\mongodb>bin\mongod --help
Allowed options:

General options:
  -h [ --help ]               show this usage information
  --version                   show version information
  -f [ --config ] arg         configuration file specifying additional options
  -v [ --verbose ]            be more verbose (include multiple times for more
                              verbosity e.g. -vvvvv)
  --quiet                     quieter output
  --port arg                  specify port number - 27017 by default
  --bind_ip arg               comma separated list of ip addresses to listen on
                              - all local ips by default
  --maxConns arg              max number of simultaneous connections - 20000 by
                              default
  --logpath arg               log file to send write to instead of stdout - has
                              to be a file, not directory
  --logappend                 append to logpath instead of over-writing
  --pidfilepath arg           full path to pidfile (if not set, no pidfile is
                              created)
  --keyFile arg               private key for cluster authentication
  --setParameter arg          Set a configurable parameter
  --auth                      run with security
  --cpu                       periodically show cpu and iowait utilization
  --dbpath arg                directory for datafiles - defaults to \data\db\
  --diaglog arg               0=off 1=W 2=R 3=both 7=W+some reads
  --directoryperdb            each database will be stored in a separate
                              directory
  --ipv6                      enable IPv6 support (disabled by default)
  --journal                   enable journaling
  --journalCommitInterval arg how often to group/batch commit (ms)
  --journalOptions arg        journal diagnostic options
  --jsonp                     allow JSONP access via http (has security
                              implications)
  --noauth                    run without security
  --nohttpinterface           disable http interface
  --nojournal                 disable journaling (journaling is on by default
                              for 64 bit)
  --noprealloc                disable data file preallocation - will often hurt
                              performance
  --noscripting               disable scripting engine
  --notablescan               do not allow table scans
  --nssize arg (=16)          .ns file size (in MB) for new databases
  --profile arg               0=off 1=slow, 2=all
  --quota                     limits each database to a certain number of files
                              (8 default)
  --quotaFiles arg            number of files allowed per db, requires --quota
  --repair                    run repair on all dbs
  --repairpath arg            root directory for repair files - defaults to
                              dbpath
  --rest                      turn on simple rest api
  --slowms arg (=100)         value of slow for profile and console log
  --smallfiles                use a smaller default file size
  --syncdelay arg (=60)       seconds between disk syncs (0=never, but not
                              recommended)
  --sysinfo                   print some diagnostic system information
  --upgrade                   upgrade db if needed

Windows Service Control Manager options:
  --install                install Windows service
  --remove                 remove Windows service
  --reinstall              reinstall Windows service (equivalent to --remove
                           followed by --install)
  --serviceName arg        Windows service name
  --serviceDisplayName arg Windows service display name
  --serviceDescription arg Windows service description
  --serviceUser arg        account for service execution
  --servicePassword arg    password used to authenticate serviceUser

Replication options:
  --oplogSize arg       size to use (in MB) for replication op log. default is
                        5% of disk space (i.e. large is good)

Master/slave options (old; use replica sets instead):
  --master              master mode
  --slave               slave mode
  --source arg          when slave: specify master as <server:port>
  --only arg            when slave: specify a single database to replicate
  --slavedelay arg      specify delay (in seconds) to be used when applying
                        master ops to slave
  --autoresync          automatically resync if slave data is stale

Replica set options:
  --replSet arg           arg is <setname>[/<optionalseedhostlist>]
  --replIndexPrefetch arg specify index prefetching behavior (if secondary)
                          [none|_id_only|all]

Sharding options:
  --configsvr           declare this is a config db of a cluster; default port
                        27019; default dir /data/configdb
  --shardsvr            declare this is a shard db of a cluster; default port
                        27018

 

E:\mongodb>start .\bin\mongod -port 10000 -dbpath data\db -logpath data\log\mdb.log

E:\mongodb>bin\mongo --help
MongoDB shell version: 2.4.8
usage: bin\mongo [options] [db address] [file names (ending in .js)]
db address can be:
  foo                   foo database on local machine
  192.169.0.5/foo       foo database on 192.168.0.5 machine
  192.169.0.5:9999/foo  foo database on 192.168.0.5 machine on port 9999
options:
  --shell                               run the shell after executing files
  --nodb                                don't connect to mongod on startup - no
                                        'db address' arg expected
  --norc                                will not run the ".mongorc.js" file on
                                        start up
  --quiet                               be less chatty
  --port arg                            port to connect to
  --host arg                            server to connect to
  --eval arg                            evaluate javascript
  -u [ --username ] arg                 username for authentication
  -p [ --password ] arg                 password for authentication
  --authenticationDatabase arg          user source (defaults to dbname)
  --authenticationMechanism arg (=MONGODB-CR)
                                        authentication mechanism
  -h [ --help ]                         show this usage information
  --version                             show version information
  --verbose                             increase verbosity
  --ipv6                                enable IPv6 support (disabled by
                                        default)

file names: a list of files to run. files have to end in .js and will exit after
 unless --shell is specified


E:\mongodb>bin\mongo -port 10000
MongoDB shell version: 2.4.8
connecting to: 127.0.0.1:10000/test
Server has startup warnings:
Sun Nov 24 11:24:51.515 [initandlisten]
Sun Nov 24 11:24:51.515 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary
.
Sun Nov 24 11:24:51.515 [initandlisten] **       32 bit builds are limited to le
ss than 2GB of data (or less with --journal).
Sun Nov 24 11:24:51.515 [initandlisten] **       Note that journaling defaults t
o off for 32 bit and is currently off.
Sun Nov 24 11:24:51.515 [initandlisten] **       See http://dochub.mongodb.org/c
ore/32bit
Sun Nov 24 11:24:51.515 [initandlisten]
Sun Nov 24 11:24:51.515 [initandlisten] ** NOTE: your operating system version d
oes not support the method that MongoDB
Sun Nov 24 11:24:51.515 [initandlisten] **       uses to detect impending page f
aults.
Sun Nov 24 11:24:51.515 [initandlisten] **       This may result in slower perfo
rmance for certain use cases
Sun Nov 24 11:24:51.515 [initandlisten]
> help
        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 wit
h time >= 1ms
        show logs                    show the accessible logger names
        show log [name]              prints out the last segment of log in memor
y, '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 f
urther iterate
        DBQuery.shellBatchSize = x   set default number of items to display on s
hell
        exit                         quit the mongo shell
> show dbs;
local   0.03125GB
> use mydb;
switched to db mydb
> show dbs;
local   0.03125GB
> db.myc.save({a:10});
> db.myc.find();
{ "_id" : ObjectId("529172a4eac97f31b4051e3b"), "a" : 10 }
> show collections;
myc
system.indexes
> show dbs;
local   0.03125GB
mydb    0.0625GB
> db.dropDatabase();
{ "dropped" : "mydb", "ok" : 1 }
> show dbs;
local   0.03125GB
> exit;

E:\mongodb>exit

 

==================================================

**************
Unclean shutdown detected.
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
*************

E:\mongodb>bin\mongod --repair --dbpath data\db

 

其他命令可以参考:

http://blog.csdn.net/wangpeng047/article/details/7705588

 

下载:

http://www.mongodb.org/downloads

https://github.com/mongodb/mongo-java-driver/downloads

 

分享到:
评论

相关推荐

    java中mongodb使用环境详细配置

    Java 中 MongoDB 使用环境详细配置是指在 Windows 平台(WinXP)上安装、运行、安装 Windows 服务的笔记,以作备忘。下面是一些重要的知识点: 1. MongoDB 的下载和安装 MongoDB 提供了多种操作系统的版本,包括 ...

    使用Flask实现Todo备忘录项目的所有代码

    在本项目中,我们将探讨如何使用Python的Flask框架与MongoDB数据库来构建一个简易的Todo备忘录应用。这个应用允许用户进行添加、更新和删除待办事项的操作,是学习Web开发的一个基础且实用的例子。 **Flask框架介绍...

    TP_SIR_mongodb

    Mongod 命令备忘录: show dbs:列出数据库的名称 使用数据库名称:允许您“进入”数据库 show collections:允许您列出 databasename 的集合 db.nomdelacollection.find():允许你列出集合的所有数据示例:db....

    备忘单:各种主题备忘单的集合

    3. **数据库管理**:SQL查询语句、数据库设计模式以及常见的数据库管理系统(如MySQL、MongoDB)的操作。 4. **操作系统**:Linux或Windows命令行快捷操作、系统管理技巧。 5. **版本控制**:Git的基本命令和工作流...

    cheat-sheets:我们的备忘单一套

    3. **数据库**:SQL基础和高级查询技巧,如SELECT语句、JOIN操作、索引优化等,也可能涵盖NoSQL数据库如MongoDB、Redis的常用命令。 4. **版本控制系统**:Git的常用命令,如clone、commit、push、pull、branch、...

    Mongo_CheatSheet:Mongo Shell备忘单和快速入门指南

    本备忘单和快速入门指南将帮助你更好地理解和使用MongoDB。 **一、MongoDB基本概念** 1. **数据库(Database)**:MongoDB中的数据存储在数据库中,每个数据库都有一个唯一的名称。 2. **集合(Collection)**:...

    Programming-cheat-sheets:您很快就能在这里找到各种编程备忘单!

    6. **版本控制系统**:Git是目前最常用的版本控制工具,备忘单会提供常用命令,如clone、add、commit、push和pull等。 7. **数据结构与算法**:栈、队列、链表、树、图、排序和搜索算法等,这些都是编程面试和日常...

    cheat_sheets:看起来很有帮助的命令。 向上

    向上”暗示了这个压缩包可能包含了各种命令行工具的备忘单,这些工具可能是用于操作系统交互、编程语言、数据处理或其他IT领域的常用命令。 描述中的“看起来很有帮助的命令。 向上”进一步强调了这些备忘单的实用...

    awesome-cheatsheets-cn::fire::fire::fire:专为国人开发者打造的备忘单-操作系统,数据库,编程语言,框架和开发工具等速查表。通过一个文件快速掌握或查找您所需的关键知识。项目上榜靠你了,觉得不错点个Star吧!:rocket::rocket:

    这里可能包括MySQL、PostgreSQL、MongoDB、Oracle等数据库的速查表。这些速查单通常包含SQL查询语法、数据库设计原则、性能优化技巧等关键信息。对于开发者而言,掌握数据库操作和优化能力是提升项目性能的关键。 ...

    Java 面试必,会直通BAT,TMD大厂

    3. **设计模式**:包括单例、工厂、观察者、装饰者、适配器、策略、代理、模板方法、建造者、命令、状态、享元、访问者、桥接、组合、迭代器、备忘录、解释器等23种经典设计模式。 4. **并发编程**:讲解Java多线程...

    【白雪红叶】JAVA学习技术栈梳理思维导图.xmind

    mongodb strom spark java语言 语言语法基础 异常 泛型 内部类 反射 序列化 nIo 匿名类 包装类 优先级 引用 语言工具类库 容器类 集合 链表 map 工具类 系统类 日期类 数字类 字符串+正则 ...

    java程序员面试之九阴真经.rar

    3. 行为型模式:观察者、模板方法、策略、职责链、命令、解释器、迭代器、备忘录、状态、访问者等。 五、数据结构与算法 1. 基本数据结构:数组、链表、栈、队列、堆、树、图等。 2. 排序算法:冒泡排序、插入排序...

    java面试题库

    - 行为型模式:责任链、命令、解释器、迭代器、访问者、备忘录、状态、策略、模板方法、观察者模式等。 6. **框架**: - Spring框架:IoC容器、AOP、MVC、Spring Boot、Spring Cloud等。 - MyBatis:SQL映射、...

    java就业面试宝典

    3. 行为型模式:掌握命令、责任链、解释器、迭代器、中介者、备忘录、观察者、状态、策略、模板方法、访问者等模式。 十、框架与中间件 1. Spring框架:理解依赖注入,掌握AOP和IoC的概念。 2. MyBatis:熟悉SQL...

    architect-awesome-java:《后端架构师技术图谱》java实现

    - **行为型模式**:策略、模板方法、观察者、迭代器、职责链、访问者、命令、状态、备忘录。 5. **Spring框架**: - **IoC(控制反转)**:Bean的生命周期、依赖注入、AOP。 - **Spring MVC**:模型-视图-控制器...

Global site tag (gtag.js) - Google Analytics