mongodb备份之导出和导入某个表

mongoexport is a utility that produces a JSON or CSV export of data stored in a MongoDB instance

WARNING:

Avoid using mongoimport and mongoexport for full instance production backups. They do not reliably preserve all rich BSON data types, because JSON can only represent a subset of the types supported by BSON. Use mongodump and mongorestore as described in MongoDB Backup Methods for this kind of functionality.

所以全量备份数据使用mongodump和mongorestore
1、导出

--host :要导出数据库 ip
--port :要导出的实例节点端口号
--username :数据库用户名
--password :数据库用户密码
--collection :要导出的表名
--db :要导出的表所在数据库名
--out :要导出的文件路径(默认为当前文件夹)

mongoexport  --collection ai_session_conversa --db ai_xbot --out ai_session_conversa.json
mongoexport  --collection ai_session_message --db ai_xbot --out ai_session_message.json

2、导入

-- host :要导入的数据库 ip
--port :要导入的实例节点端口号
--username :数据库用户名
--password :数据库用户密码
--collection :要导入的表名
--db :要导入的表所在数据库名
--file :要导入的源文件路径(默认为当前文件夹)

mongoimport  --collection ai_session_conversa --db ai_xbot --file ai_session_conversa.json

交流群:725450393
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值