mongo_数据导入导出
如果存在数据
{
"_id" : ObjectId("5dba4f650088f730f5dd6083"),
"status" : 1,
"checked_remark" : "",
"infosecurity" : 10,
"create_date" : 1572451200,
"description" : "主机访问了XCodeGhost病毒通信域名",
"accepted_at" : 0,
"dispatch_date" : 0,
"hole_id" : "",
"dealt_at" : 0,
"infosecuritysub" : 113,
"deal_duration" : 0,
"rejected_remark" : "",
"found_at" : 1572490877,
"dealt_remark" : "",
"expired_at" : 0,
"impact" : [
1
],
"branch_id" : 2,
"src_id" : "5dba4e89a93738764b00f412",
"dispatched_at" : 0,
"level" : 4,
"is_delayed" : 0,
"created_at" : 1572491109,
"ignored_at" : 0,
"rejected_at" : 0,
"rule_id" : 104012,
"src_ip" : "1.1.1.1",
"notify_no" : "",
"forever_manual" : 0,
"checked_at" : 0,
"src_type" : 1,
"deal_date" : 0,
"event_key" : "5dba4e89a93738764b00f412|1.1.1.1|2|"
}
导入json 数据到 mongo表中
需要将该json 导入到表中, 这可以使用 mongoimport
mongoimport --host localhost --port 27017 --username 用户名 --password 123456 --collection 端口 --db 数据库名 --file /root/shaql/host_locations.json
/root/shaql/host_locations.json 为要导入的json文件
将mongo表中的数据导出为json文件: mongoexport
mongoexport --host localhost --port 27017 --username ezsonaruser --password 123456 --collection host_locations --db ezsonar_25 --out /root/host_locations.json
- --host 后的 localhost:要导出数据库 ip
- --port 后的 27017:要导出的实例节点端口号
- --username 后的 ezsonaruser:数据库用户名
- --password 后的 123456:数据库用户密码
- --collection 后的 widgets-test:要导出的表名
- --db 后的 ezsonar_25:要导出的表所在数据库名
- --out 后的 /root/host_locations.json:要导出的文件路径(默认为当前文件夹)

浙公网安备 33010602011771号