您的位置 首页 php

在MongoDB上如何进行数据的导入与导出

MongoDB是一个基于分布式文件存储的数据库,下面我将就MongoDB的导入与导出给大家作出简要叙述,感兴趣的朋友可以了解一下。

一.导入与导出可以操作本地的mongodb也可以是远程的mongodb,通用选项:

-h host   主机--port port    端口-u username 用户名-p password   密码

如果mongodb没有账户密码并且是从本地导可以忽略上面四个参数

二.导出:

使用mongodb/bin/mongoexport文件:

cd /usr/local/mongodb./bin/mongoexport -d shop -c order -f name,content -q '{_id:{$lte:100}}' -o order.json-d  库名-c  表名-f  field1,field2...要导出的字段-q  查询条件-o  导出的文件名  

默认导出的数据格式为json格式,如果为了便于和传统数据库交换数据想导出csv格式需要指定文件类型–csv,上面的导出命令可以修改为:

./bin/mongoexport -d shop -c order -f name,content -q '{_id:{$lte:100}}' --csv -o order.csv

三.导入:

./bin/mongoimport -d shop -c good --type json --file ./order.json-d 导入的数据库-c 导入的表(不存在自动创建)--type  csv | json(默认json)--file 文件路径

注意:当导入的文件格式为csv时,需要增加一个–headerline,使用第一行作为字段名称:

./bin/mongoimport -d shop -c good --type csv --headerline --file ./order.csv

四.二进制导出

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

./bin/mongodump -d shop  -c order -d  库名-c  表名(不指定表默认导出全部表)-q  查询表达式-o  文件路径名(默认导出到mongodb/dump目录下)

导出之后在mongodb/dump/databaseName/目录下有一个.bson文件和一个.json文件  

[root@sx45a8 mongodb]# cd dump[root@sx45a8 dump]# lsshop[root@sx45a8 dump]# cd shop[root@sx45a8 shop]# lsorder.bson  order.metadata.json

五.二进制导入

./bin/mongorestore -d test --dir dump/shop/-d 导入的库名--dir 文件目录

二进制备份不仅可以备份数据还可以备份索引,而且备份比较小

相关教程:MongoDB视频教程

以上就是在MongoDB上如何进行数据的导入与导出的详细内容,更多请关注求知技术网其它相关文章!

文章来源:智云一二三科技

文章标题:在MongoDB上如何进行数据的导入与导出

文章地址:https://www.zhihuclub.com/5574.shtml

关于作者: 智云科技

热门文章

评论已关闭

37条评论

  1. 4 mL s with tamsulosin placebo , but differences were not significantly different P 0 The confidence I have now is amazing

  2. Compared with sildenafil and vardenafil, tadalafil is much less inhibitory for PDE6, and it is over 700 times more potent for PDE5 than PDE6 ICOS 2008 The price per pill of Cialis 5 mg at a local U

  3. Prolonged Erection A large number of Viagra users have shown concerns and doubts regarding the safety and effectiveness of its generic

  4. This study was designed to determine if endometrial thickness should be used as an inclusion or exclusion criterion for CC-IVF.

  5. The time history of deformation typically showed an initial rapid phase followed by a slow creep, similar to the behavior of peripheral blood leukocytes studied previously 13.

  6. A nursing mother was diagnosed with breast cancer and started on tamoxifen 20 mg daily at 8 am Interestingly, BMI seems predictive of L effect on bone health among premenopausal but not postmenopausal pts; these findings are consistent with previous observations

  7. In contrast, the district court in In re Actos End Payor Antitrust Litigation 41 dismissed the plaintiffs antitrust claims on the basis that the plaintiffs failed to establish that the acceleration clauses in the brand drug company s settlements with the generic drug companies constituted payments under Actavis

  8. This Canadian study included 95 women with a confirmed BRCA mutation who had prophylactic bilateral salpingo oophorectomy between January 2000 and May 2013

  9. 4 EI24 has a multifaceted role against tumor progression that is regulated by both EMT and inflammation

  10. Chin J Cancer 29 163 166 This result indicates that tamoxifen s cytotoxicity may result from improved drug internalization through encapsulation into the SLN matrix and endocytosis 21

  11. The remodeling appears to start with the bone lining cells that recruit osteoclasts to reabsorb the old bone, and these in turn stimulate a wave of new bone formation by the osteoblasts Indeed, CQ and HCQ anti malarial drugs, 4 AQ are today commonly used in rheumatology 1, 2, 3, especially for the treatment of systemic lupus erythematosus

  12. Gullapalli K, Basnet N, Mosalem O, Gogineni V, Agarwal P, Boumegouas M, Tikaria R The overall safety and tolerability of Reclast was similar to the active control

  13. Journal of the National Cancer Institute, 1996, 88 21, 1543 1549 added to CENTRAL 31 January 1998 1998 Issue 1

  14. Among the volunteers, among the supporters in the magnificent venues across the city, even on the sofas of the nation, suddenly our collective attitude had swung in an upwards trajectory

  15. Monitor Closely 1 ethinylestradiol will increase the level or effect of rasagiline by affecting hepatic enzyme CYP1A2 metabolism Chinese J Vet Sci Technol

  16. Even if they do not benefit directly from the clinical trial, their participation may yield future benefits for people with uterine cancer

  17. com 20 E2 AD 90 20Viagra 20Ilman 20Resepti 20Netist 20 20Viagra 20Online 20Jelly viagra ilman resepti netist This is the first time since stereoscoping 3D techniques were perfected in the last century that the premise of what causes depth perception has changed

  18. Data from clinical studies indicate that regular consumption of green tea may decrease the risk of hypertension 1 and positively affect mood

  19. Bradi Granger 1, Adam Devore 2, Lisa Kaltenbach 2, Gregg Fonarow 3, Hussein Al Khalidi 2, Nancy Albert 4, Eldrin Lewis 5, Javed Butler 6, Ileana Pina 7, Paul Heidenreich 8, Larry Allen 9, Clyde Yancy 10, Lauren Cooper 11, Michael Felker 2, Andrew McRae III 12, David Lanfear 13, Robert Harrison 2, Maghee Disch 14, Dan Ariely 15, Julie Miller 15, Christopher Granger 16, Adrian Hernandez 2

  20. Dose related somnolence and CNS depression are the most common adverse effects associated with the use of suvorexant Adapter ligated library was completed by PCR with Illumina PE primers

  21. Your doctor may, understandably, not be able to provide a clear answer to this question because chemotherapy is given often in combination with other drugs, and physicians and scientists have yet to completely tease out the effects of one agent versus another or differentiate how the various agents interact with the patient s cancer

  22. Taking senna appears to be as effective as lactulose, psyllium, and docusate for relieving constipation in people taking opioids or loperamide Arunabh S, Pollack S, Yeh J, Aloia JF

  23. com 20 E2 AD 90 20Viagra 20Geciktirici 20Krem 20Yorumlar 20 20Superdrug 20Viagra 20Connect superdrug viagra connect Any positive Motown impact on the insurance business will come if and only if Detroit is not the start of wave of defaults across U Garlic fingered chefs

  24. It is disappointing that of the hundreds of people who experience brain stimulation and recording in surgery, only a handful are studied systematically

网站地图