gpt4 book ai didi

mongodb - 如何在我的 meteor 应用程序数据库中使用 mongoimport?

转载 作者:IT老高 更新时间:2023-10-28 13:06:43 25 4
gpt4 key购买 nike

我可以使用 mongoimport 将 csv 数据导入非 meteor mongodb 数据库,但我不知道如何将 csv 导入我的 meteor 应用程序数据库。

我学会了如何为我的 meteor 应用程序 (meteor mongo) 运行 mongo shell,但我无法从 shell 运行 mongoimport

mongoimport 的 mongodb 文档说

In this example, mongoimport imports the csv formatted data in the /opt/backups/contacts.csv into the collection contacts in the users database on the MongoDB instance running on the localhost port numbered 27017.

mongoimport --db users --collection contacts --type csv --file /opt/backups/contacts.csv

但是当我运行 mongod,启动我的 meteor 应用程序并运行 mongoimport 时,它会导入我的 test 数据库,而不是我的应用程序数据库。

我阅读了这篇 stackoverflow 帖子评论:

Use mongoexport to dump your collections individually, then mongoimport to import the files into the db named meteor in the meteor mongodb instance. The meteor mongo instance runs on port 3002 with bind_address 127.0.0.1, and the data files are in the meteor project subdirectory .meteor/local/db

但我不明白如何连接到该实例或如何使用 mongoimport 命令定位它。

最佳答案

看来我刚刚在 Rahuls wonderful answer 中回复了您的评论.无论如何,从 mongodb.org 为您的操作系统(或像 macports 之类的包管理器)下载 mongodb,并使用 bin 文件夹中提供的工具。 mongoimport 不是 mongo shell 中的命令,它是一个单独运行的可执行文件。

别忘了把端口放进去(如果你在 3000 运行你的 meteor 实例,通常是 3001),db 通常也是 meteor 而不是用户当你运行它时

mongoimport -h localhost:3001 --db meteor --collection contacts --type csv --file /opt/backups/contacts.csv

关于mongodb - 如何在我的 meteor 应用程序数据库中使用 mongoimport?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15365747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com