文章详情

短信预约信息系统项目管理师 报名、考试、查分时间动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

how to export cvs data from mongodb on centos7

2014-12-03 14:05

关注

how to export cvs data from mongodb on centos7

Install mongodb-org-tools

[lwk@qwfys:~]$ sudo dnf install mongodb-org-tools
[sudo] password for lwk: 
Last metadata expiration check: 1:05:23 ago on Thu 16 Jul 2020 11:58:35 AM CST.
Dependencies resolved.
==============================================================================================================================================================================================================================================
 Package                                                        Architecture                                        Version                                                    Repository                                                Size
==============================================================================================================================================================================================================================================
Installing:
 mongodb-org-tools                                              x86_64                                              4.2.8-1.el8                                                mongodb-org                                               62 M

Transaction Summary
==============================================================================================================================================================================================================================================
Install  1 Package

Total download size: 62 M
Installed size: 128 M
Is this ok [y/N]: y
Downloading Packages:
mongodb-org-tools-4.2.8-1.el8.x86_64.rpm                                                                                                                                                                      4.1 MB/s |  62 MB     00:15    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                         4.0 MB/s |  62 MB     00:15     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                      1/1 
  Installing       : mongodb-org-tools-4.2.8-1.el8.x86_64                                                                                                                                                                                 1/1 
  Running scriptlet: mongodb-org-tools-4.2.8-1.el8.x86_64                                                                                                                                                                                 1/1 
  Verifying        : mongodb-org-tools-4.2.8-1.el8.x86_64                                                                                                                                                                                 1/1 

Installed:
  mongodb-org-tools-4.2.8-1.el8.x86_64                                                                                                                                                                                                        

Complete!
[lwk@qwfys:~]$ 

Find specific data from mongodb

[lwk@qwfys:~]$ mongo -u lanzhou -p --host 192.168.3.88 --authenticationDatabase lanzhou
MongoDB shell version v4.2.8
Enter password: 
connecting to: mongodb://192.168.3.88:27017/?authSource=lanzhou&compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("6eb0c76d-338a-46ff-aa5a-65f468b76875") }
MongoDB server version: 4.2.8
> db.artists.find().pretty()
{
	"_id" : ObjectId("5f0fc3322d6c5971111129f4"),
	"artistname" : "The Tea Party"
}
{ "_id" : ObjectId("5f0fc3882d6c5971111129f5"), "artistname" : "The Kooks" }
{ "_id" : ObjectId("5f0fc3882d6c5971111129f6"), "artistname" : "Bastille" }
{
	"_id" : ObjectId("5f0fc3882d6c5971111129f7"),
	"artistname" : "Gang of Four"
}
{
	"_id" : ObjectId("5f0fc3b62d6c5971111129f8"),
	"artistname" : "Deep Purple",
	"albums" : [
		{
			"album" : "Machine Head",
			"year" : 1972,
			"genre" : "Rock"
		},
		{
			"album" : "Stormbringer",
			"year" : 1974,
			"genre" : "Rock"
		}
	]
}
{
	"_id" : ObjectId("5f0fc4032d6c5971111129f9"),
	"artistname" : "Robben Ford",
	"albums" : [
		{
			"album" : "Bringing it Back Home",
			"year" : 2013,
			"genre" : "Blues"
		},
		{
			"album" : "Talk to Your Daughter",
			"year" : 1988,
			"genre" : "Blues"
		}
	]
}
{
	"_id" : ObjectId("5f0fc4032d6c5971111129fa"),
	"artistname" : "Snoop Dogg",
	"albums" : [
		{
			"album" : "Tha Doggfather",
			"year" : 1996,
			"genre" : "Rap"
		},
		{
			"album" : "Reincarnated",
			"year" : 2013,
			"genre" : "Reggae"
		}
	]
}
{
	"_id" : 2,
	"artistname" : "Prince",
	"address" : {
		"street" : "Audubon Road",
		"city" : "Chanhassen",
		"state" : "Minnesota",
		"country" : "United States"
	}
}
{
	"_id" : 3,
	"artistname" : "Moby",
	"albums" : [
		{
			"album" : "Play",
			"year" : 1999,
			"genre" : "Electronica"
		},
		{
			"album" : "Long Ambients 1: Calm. Sleep.",
			"year" : 2016,
			"genre" : "Ambient"
		}
	]
}
{ "_id" : 4, "artistname" : "Rush" }
>

Export cvs data from mongodb


mongoexport --db lanzhou -u lanzhou -p Gah6kuP7ohfio4 --host 192.168.3.88 --collection artists --type=csv --fields _id,artistname --out /home/lwk/Downloads/.tmp/artists.csv
阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯