<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-86  評論-33  文章-0  trackbacks-0

    Import Export Tools

    These tool just work with the raw data (the documents in the collection); they do not save, or load, the metadata like the defined indexes or (capped) collection properties. You will need to (re)create those yourself in a separate step, before loading that data. Vote here to change this.

    mongoimport

    This utility takes a single file that contains 1 JSON/CSV/TSV string per line and inserts it. You have to specify a database and a collection.

    options:
                --help                  produce help message
                -v [ --verbose ]        be more verbose (include multiple times for more
                			    verbosity e.g. -vvvvv)
                -h [ --host ] arg       mongo host to connect to ("left,right" for pairs)
                -d [ --db ] arg         database to use
                -c [ --collection ] arg collection to use (some commands)
                -u [ --username ] arg   username
                -p [ --password ] arg   password
                --dbpath arg            directly access mongod data files in the given path,
                			    instead of connecting to a mongod instance - needs to
                			    lock the data directory, so cannot be used if a
                			    mongod is currently accessing the same path
                --directoryperdb        if dbpath specified, each db is in a separate
                directory
                -f [ --fields ] arg     comma seperated list of field names e.g. -f name,age
                --fieldFile arg         file with fields names - 1 per line
                --ignoreBlanks          if given, empty fields in csv and tsv will be ignored
                --type arg              type of file to import.  default: json (json,csv,tsv)
                --file arg              file to import from; if not specified stdin is used
                --drop                  drop collection first
                --headerline            CSV,TSV only - use first line as headers
                

    mongoexport

    This utility takes a collection and exports to either JSON or CSV. You can specify a filter for the query, or a list of fields to output.

    Neither JSON nor TSV/CSV can represent all data types. Please be careful not to lose or change data (types) when using this. For full fidelity please use mongodump.

    If you want to output CSV, you have to specify the fields in the order you want them.

    Example

    options:
                --help                  produce help message
                -v [ --verbose ]        be more verbose (include multiple times for more
                			    verbosity e.g. -vvvvv)
                -h [ --host ] arg       mongo host to connect to ("left,right" for pairs)
                -d [ --db ] arg         database to use
                -c [ --collection ] arg collection to use (some commands)
                -u [ --username ] arg   username
                -p [ --password ] arg   password
                --dbpath arg            directly access mongod data files in the given path,
                			    instead of connecting to a mongod instance - needs to
                			    lock the data directory, so cannot be used if a
                			    mongod is currently accessing the same path
                --directoryperdb        if dbpath specified, each db is in a separate
                directory
                -q [ --query ] arg      query filter, as a JSON string
                -f [ --fields ] arg     comma seperated list of field names e.g. -f name,age
                --csv                   export to csv instead of json
                -o [ --out ] arg        output file; if not specified, stdout is used
                

    mongodump

    This takes a database and outputs it in a binary representation. This is mostly used for doing hot backups of a database.

    If you're using sharding and try to migrate data this way, this will dump shard configuration information and overwrite configurations upon restore.
    options:
                --help                   produce help message
                -v [ --verbose ]         be more verbose (include multiple times for more
                			     verbosity e.g. -vvvvv)
                -h [ --host ] arg        mongo host to connect to ("left,right" for pairs)
                -d [ --db ] arg          database to use
                -c [ --collection ] arg  collection to use (some commands)
                -u [ --username ] arg    username
                -p [ --password ] arg    password
                --dbpath arg             directly access mongod data files in the given path,
                			     instead of connecting to a mongod instance - needs
                			     to lock the data directory, so cannot be used if a
                				     mongod is currently accessing the same path
                --directoryperdb         if dbpath specified, each db is in a separate
                directory
                -o [ --out ] arg (=dump) output directory
                

    Example: Dumping Everything

    To dump all of the collections in all of the databases, run mongodump with just the --host:

    $ ./mongodump --host prod.example.com
                connected to: prod.example.com
                all dbs
                DATABASE: log    to   dump/log
                log.errors to dump/log/errors.bson
                713 objects
                log.analytics to dump/log/analytics.bson
                234810 objects
                DATABASE: blog    to    dump/blog
                blog.posts to dump/log/blog.posts.bson
                59 objects
                DATABASE: admin    to    dump/admin
                

    You'll then have a folder called "dump" in your current directory.

    If you're running mongod locally on the default port, you can just do:

    $ ./mongodump
                

    Example: Dumping a Single Collection

    If we just want to dump a single collection, we can specify it and get a single .bson file.

    $ ./mongodump --db blog --collection posts
                connected to: 127.0.0.1
                DATABASE: blog        to     dump/blog
                blog.posts to dump/blog/posts.bson
                59 objects
                

    mongorestore

    This takes the output from mongodump and restores it.

    usage: ./mongorestore [options] [directory or filename to restore from]
                options:
                --help                  produce help message
                -v [ --verbose ]        be more verbose (include multiple times for more
                			    verbosity e.g. -vvvvv)
                -h [ --host ] arg       mongo host to connect to ("left,right" for pairs)
                -d [ --db ] arg         database to use
                -c [ --collection ] arg collection to use (some commands)
                -u [ --username ] arg   username
                -p [ --password ] arg   password
                --dbpath arg            directly access mongod data files in the given path,
                				    instead of connecting to a mongod instance - needs to
                				    lock the data directory, so cannot be used if a
                			    mongod is currently accessing the same path
                --directoryperdb        if dbpath specified, each db is in a separate
                directory
                --drop                  drop each collection before import
                --objcheck              validate object before inserting
    posted on 2010-07-05 17:52 Derek.Guo 閱讀(1196) 評論(0)  編輯  收藏 所屬分類: NoSqlDB

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    MSN:envoydada@hotmail.com QQ:34935442
    主站蜘蛛池模板: 亚洲中文字幕无码爆乳av中文| 亚洲av日韩av不卡在线观看| 曰曰鲁夜夜免费播放视频| 99视频全部免费精品全部四虎| 在线观看亚洲视频| 国产成人高清亚洲一区91| 午夜毛片不卡高清免费| 亚洲?V无码乱码国产精品| 亚洲熟妇无码八AV在线播放| 亚洲国产av美女网站| 黄网站色视频免费看无下截 | a级毛片在线免费| 1000部国产成人免费视频| 亚洲国产成人精品无码久久久久久综合 | 亚洲一区日韩高清中文字幕亚洲 | 国产精品高清视亚洲一区二区| 亚洲AV人无码激艳猛片| 中文字幕成人免费高清在线| 成人无码区免费视频观看| 91麻豆精品国产自产在线观看亚洲| 亚洲国产精品成人久久蜜臀| 无码日韩人妻AV一区免费l| 免费国产黄网站在线观看可以下载| 成人无码视频97免费| 亚洲va中文字幕无码久久| 国产精品亚洲片在线花蝴蝶 | 国产精品99爱免费视频| 好吊妞在线新免费视频| 亚洲丰满熟女一区二区哦| 水蜜桃视频在线观看免费播放高清 | 亚洲性在线看高清h片| 中文字幕免费在线看电影大全 | 激情综合亚洲色婷婷五月APP| 亚洲老熟女五十路老熟女bbw| 亚洲AV日韩AV一区二区三曲| 黄页网站在线看免费| 国产亚洲精品2021自在线| 婷婷久久久亚洲欧洲日产国码AV | 亚洲av无码专区在线电影天堂| 污视频在线免费观看| 最新精品亚洲成a人在线观看|