mongo 导入导出数据 mongoexport mongoimport

导出:

mongoexport 选项 如下


–host 指定mongo的ip和端口
-d 指定数据库名
-c 指定表名
-f 指定列名 (逗号隔开)
-o 指定输出路径
-q 指定查询语句

--type 执行文件类型

 

进入mongoexport所在目录:

mongoexport --host ip:27017 -u user -p password --authenticationDatabase admin -d databaseName -c collectionname --type=csv -f name -o ./record.csv -q ‘{“uptime”:{"$gte":1555286670}}’

mongoexport --host 192.168.0.221 --port 20058 -d test -c salary --type json --out D:\abc.json

mongoexport -d myDB -c user -f _id,name,password,adress --csv -o ./user.csv

 

 

导入:

 

–host 指定mongo的ip和端口
-d 指定数据库名
-c 指定表名
--file 指定输入路径
-q 指定查询语句

--type 执行文件类型

mongoimport --host 192.168.0.221 --port 20058 -d test -c salary --type json --file D:\abc.json

你可能感兴趣的:(mongodb)