Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of the mongoexport command for exporting mongo databases

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The MongoDB management tool I use is Robo3T. Today, I need to export the collection data from the database, but I don't know how to play Robo3T. I don't seem to have the function of direct export, so I looked it up on the Internet and found the command mongoexport, which can easily export the data.

Execute the following command on the mongo machine

Mongoexport-h 127.0.0.1-d nginxlog-u nginxlog-p XXXX-c tabo_201711-f ModuleName,ButtonName,Link,cunt-- csv-o tabo_201711.csv

The collection tabo_201711 of the database nginxlog is exported above, and the data is exported in csv format.

-h indicates the host IP or hostname

-d represents the database name

-u user name

-p password

-c represents the collection name

-f represents the field of the selected collection

-o represents the exported file name.

If you are exporting in csv format, you need to specify the fields of the exported collection

In which directory, the export file is saved in that directory, and then downloaded to the local Windows on the line, the export file is .csv format, but use excel to open Chinese garbled, because in the simplified Chinese environment, excel open csv files are ANSI encoding by default, if the CSV file encoding for utf-8, Unicode and other coding may appear file garbled situation.

Solution:

Open the csv file using notepad

Click the menu: file-Save as, select ANSI for encoding

After saving, and then use Excel to open this file, there will be no garbled.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report