Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export mlab online database to file

I've been given a database hosted on mlab. I'm trying to download the files off of the database and onto my computer. How may I go about that? I should add I have never worked with mlab or MongoDB before. All I want to do is download the files in some format (such as JSON or CSV) and then process them with a python script I have

I saw the command mongoexport might do the trick but I couldn't figure out how to use it. Should I run on my cmd? It isn't recognized as a command on my computer, what do I need to download to fix that?

Another thing I saw is pymongo. If anyone knows how to use pymongo or python in general to export the data I would love to hear it.

like image 511
user3767096 Avatar asked Mar 31 '18 09:03

user3767096


1 Answers

Mongoexport is a tool which is installed with MongoDB. To get mongoexport, install MongoDB from this page: https://www.mongodb.com/download-center#production.

When you have MognoDB installed, open cmd and navigate to where the tools are installed (by default the location is C:\Program Files\MongoDB\Server\3.6\bin):

cd C:\Program Files\MongoDB\Server\3.6\bin

From there you can run the export commands listed in the mLab tools tab. For example, to export to JSON:

mongoexport -h ds012345.mlab.com:12345 -d <database> -c <collection> -u <user> -p <password> -o <output file>
like image 123
tfogo Avatar answered Nov 20 '22 16:11

tfogo