导出 | mongoexport -h dbhost -d dbname -c collectionname -f collectionKey -o dbdirectory | -h: MongoDB所在服务器地址 -d: 需要恢复的数据库实例 -c: 需要恢复的集合 -f: 需要导出的字段(省略为所有字段) -o: 表示导出的文件名 |
导入 | mongoimport -d dbhost -c collectionname –type csv –headerline –file | -type: 指明要导入的文件格式 -headerline: 批明不导入第一行,因为第一行是列名 -file: 指明要导入的文件路径 |
导出 mongoexport -h xxxxipxxxx -d dbName -c articles -o ~/articles.txt
导入 mongoimport -h xxxxxxxxxx -d dbName -c articles ~/articles.txt