返回顶部
首页 > 资讯 > 数据库 >how to export cvs data from mongodb on centos7
  • 282
分享到

how to export cvs data from mongodb on centos7

howtoexportcvsdatafrommongodboncentos7 2014-12-03 14:12:25 282人浏览 无得
摘要

Install mongoDB-org-tools [lwk@qwfys:~]$ sudo dnf install monGodb-org-tools [sudo] passWord for lwk: Last metadata expi

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
您可能感兴趣的文档:

--结束END--

本文标题: how to export cvs data from mongodb on centos7

本文链接: https://lsjlt.com/news/7268.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作