mongodb 数据备份导入导出
来源:互联网 发布:书生软件 百度百科 编辑:程序博客网 时间:2024/05/15 07:53
(1)mongoDB导出(mongoexport).
可以通过运行命令:./mongoexport --help
./mongoexport --helpoptions: --help produce help message -v [ --verbose ] be more verbose (include multiple times for more verbosity e.g. -vvvvv) --version print the program's version and exit -h [ --host ] arg mongo host to connect to ( <set name>/s1,s2 for sets) --port arg server port. Can also use --host hostname:port --ipv6 enable IPv6 support (disabled by default) -u [ --username ] arg username -p [ --password ] arg password --dbpath arg directly access mongod database files in the given path, instead of connecting to a mongod server - 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 --journal enable journaling -d [ --db ] arg database to use -c [ --collection ] arg collection to use (some commands) -f [ --fields ] arg comma separated list of field names e.g. -f name,age --fieldFile arg file with fields names - 1 per line -q [ --query ] arg query filter, as a JSON string --csv export to csv instead of json -o [ --out ] arg output file; if not specified, stdout is used --jsonArray output to a json array rather than one object per line -k [ --slaveOk ] arg (=1) use secondaries for export if available, default true参数说明。
例如我导出数据库中的一张表。
./mongoexport -h 127.0.0.1 --port 27017 -d upload -c video_encode_history -u uts -p u.l7a@bj -f mid,createTime,imgHttpPath -q '{vtype:"1",status:30,imgHttpPath:{"$ne":null}}' --csv -o history.txt
(2)mongodb 导入工具 mongodimport
运行帮助命令:./mongoimport --help
options: --help produce help message -v [ --verbose ] be more verbose (include multiple times for more verbosity e.g. -vvvvv) --version print the program's version and exit -h [ --host ] arg mongo host to connect to ( <set name>/s1,s2 for sets) --port arg server port. Can also use --host hostname:port --ipv6 enable IPv6 support (disabled by default) -u [ --username ] arg username -p [ --password ] arg password --dbpath arg directly access mongod database files in the given path, instead of connecting to a mongod server - 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 --journal enable journaling -d [ --db ] arg database to use -c [ --collection ] arg collection to use (some commands) -f [ --fields ] arg comma separated 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 --upsert insert or update objects that already exist --upsertFields arg comma-separated fields for the query part of the upsert. You should make sure this is indexed --stopOnError stop importing at first error rather than continuing --jsonArray load a json array, not one item per line. Currently limited to 4MB.
导出命令:/usr/local/mongodb/bin/mongoimport --username=uts --password=password -h 127.0.0.1 --port 27017 -d upload -c c_cloud video.json
远程连接到其他mongoDB机器上:
/usr/local/mongodb/bin/mongo --username=uts --password=u.l7a@bj host:port/upload
- mongodb 数据备份导入导出
- mongodb数据导入导出以及备份恢复
- Mongodb数据导入导出以及备份恢复
- mongodb数据导入导出以及备份恢复
- mongodb数据导入导出以及备份恢复
- mongodb数据的导入导出,备份恢复
- mongodb数据导入导出以及备份恢复
- mongodb数据导入导出以及备份恢复
- mongodb数据导入导出 备份恢复
- mongodb数据导入导出以及备份恢复
- mongodb数据导入导出以及备份恢复
- mongodb数据导入导出以及备份恢复
- mongodb数据导入导出以及备份恢复
- MongoDB 导出导入备份恢复数据实例
- MongoDB 导出导入备份恢复数据实例
- mongodb数据导入导出以及备份恢复(二)
- mongodb数据导入导出以及备份恢复(三)
- MongoDB 导出导入备份恢复数据详解及实例
- springMVC基础及应用视频(2)
- Git 修改提交信息
- Android内存泄漏调试
- Android网络相关---上网流程
- SDUT 1465 公共因子
- mongodb 数据备份导入导出
- poj2406
- python中的异常处理+日志例子
- JavaScript递归遍历树
- 关于ViewPager、ViewFilpper、ViewFlow三种实现水平向滑动方式的比较
- struts2访问web元素
- ALSA asound.conf
- semaphore与Mutex
- iOS真机调试常见错误及解决方案