MongoDB 学习笔记之 MongoDB导入导出

mac2022-06-30  65

MongoDB数据导入导出:

 

mongoexport:

-host 机器

-port 端口

-u 用户名

-p 密码

-d 库名

-c 表名

-f 列名

-o 导出的文件名

-q 查询条件

--csv 导出csv格式

 

./mongoexport --host hadoop1 --port 27017 -u sky -p **** --authenticationDatabase=admin -d test -c bar -f title,content -q '{_id: {$lte: 10}}' -o ./test.bar.json --csv

mongoimport:

-d 导入到的数据库

-c 导入到的表

--type csv/json(默认)

--file 备份文件路径

 

./mongoimport --host hadoop1 --port 27017 -u sky -p ***** --authenticationDatabase=admin -d test -c bar2 --type csv --fields title,content --file ./test.bar.json

 

./mongoimport --host hadoop1 --port 27017 -u sky -p ***** --authenticationDatabase=admin -d test -c bar2 --type csv --headerline --file ./test.bar.json

mongodump:

mongodump 导出二进制bson结构数据及其索引信息。

-d 库名

-c 表名

-f 列名

 

./mongodump --host hadoop1 --port 27017 -u sky -p ***** --authenticationDatabase=admin -d test

mongorestore:

mongorestore 导入二进制文件。

 

./mongorestore --host hadoop1 --port 27017 -u sky -p ***** --authenticationDatabase=admin --db test2  dump/test

 

转载于:https://www.cnblogs.com/AK47Sonic/p/7368510.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)