简体   繁体   English

在Windows中将数据从.csv文件导入到mongodb数据库中

[英]import data into mongodb databse from .csv file in windows

I have mongodb running in remote ubuntu server say IP:192.168.2.10 and Port:27017 . 我在远程ubuntu server运行mongodb ,说IP:192.168.2.10 and Port:27017 I access mongodb through mongoose and node.js . 我通过mongoosenode.js访问mongodb Now I want to import data from .csv to mongodb . 现在,我想将数据从.csv导入到mongodb I know about mongoImport but I have no idea how to use it from windows and where to start in windows . 我知道mongoImport但我不知道如何在windows使用它以及从windows何处开始。 I have installed node.js and mongoose using npm in my windows system. 我已经在Windows系统中使用npm安装了node.js和mongoose。 I read about mongoImport says it should run from command prompt. 我读到有关mongoImport ,该文件应从命令提示符运行。 In windows cmd prompt when I run 在Windows cmd提示符下运行时

mongoimport --host 192.168.2.10 --port 27017 --collection Attributes --db Master --file <P:\Attributes.csv 

I get this error. 我得到这个错误。

ReferenceError: mongoimport is not defined ReferenceError:未定义mongoimport

Should I install mongodb in windows, I don't think so. 我应该在Windows中安装mongodb吗,我不这么认为。 What should I do? 我该怎么办?

The primary mistake people do is try to import the csv file by issuing the mongoimport command while they are inside mongo Shell. 人们所做的主要错误是尝试在mongo Shell内时通过发出mongoimport命令来导入csv文件。 The correct way of doing it is outside mongo shell. 正确的做法是在mongo shell之外。 And ensure that you have the binary that you are trying to execute. 并确保您拥有要执行的二进制文件。 In this case it is "mongoimport". 在这种情况下,它是“ mongoimport”。

Yes you will have to get mongodb executable in windows. 是的,您将必须在Windows中获得mongodb可执行文件。

After getting that, go to the bin directory in your mongodb installation and you will find the mongoimport.exe there. 收到之后,转到mongodb安装中的bin目录,您将在其中找到mongoimport.exe。

Execute your command from there. 从那里执行命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM