MongoDB Atlas 的 mongoimport 不工作(连接字符串?)
mongoimport for MongoDB Atlas not working (connection string?)
我正在尝试将一些数据从我计算机上的 csv 文件导入到 Atlas 上的集群。我无法让它工作或在这里找到答案。我已经将相同的文件导入到我计算机上的本地数据库中,但我无法让它与 Atlas 一起使用。我认为问题出在我的连接字符串上,但我不知道我做错了什么。
Mongoimport 命令:
mongoimport --uri "mongodb://<username>:<password>@<clustername>-<string(private?)>.mongodb.net/<database>?authSource=admin&ssl=true" --collection <cname> --drop --type csv --file <path/to/file.csv --headerline
来自 MongoDB Atlas 的连接字符串:
mongo "mongodb+srv://<clustername>-<string(private?)>.mongodb.net/test" --username <username>
错误:
error connecting to host: could not connect to server: server selection error: server
selection timeout, current topology: { Type: Single, Servers: [{ Addr: <clustername>-
<string(private?)>.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error:
connection() : dial tcp: lookup <clustername>-<string(private?)>.mongodb.net on 127.0.0.53:53: no such
host }, ] }
我已经尝试了所有我能想到的,这似乎是我能得到的最接近的。在我看来,我的连接字符串有误,但我不知道如何解决。我刚接触数据库,尤其是 MongoDB。非常感谢任何帮助。
注意:我在终端中 运行 而不是 mongo shell。导入工作在我的本地机器上使用相同的文件。
尝试从 mongoimport 中的 uri 中删除 ssl=true 参数,因为您正在命令中传递客户端和 ca 证书。
还有一个建议,在 uri 中使用集群的所有主机名。如果您的集群有多个节点,通常就是这种情况。
或者:
在 altas 页面中查找命令行工具。它作为 mongoimport 到集群的模板命令。
希望对您有所帮助。
点击展开按钮,然后点击命令行工具
我正在尝试将一些数据从我计算机上的 csv 文件导入到 Atlas 上的集群。我无法让它工作或在这里找到答案。我已经将相同的文件导入到我计算机上的本地数据库中,但我无法让它与 Atlas 一起使用。我认为问题出在我的连接字符串上,但我不知道我做错了什么。
Mongoimport 命令:
mongoimport --uri "mongodb://<username>:<password>@<clustername>-<string(private?)>.mongodb.net/<database>?authSource=admin&ssl=true" --collection <cname> --drop --type csv --file <path/to/file.csv --headerline
来自 MongoDB Atlas 的连接字符串:
mongo "mongodb+srv://<clustername>-<string(private?)>.mongodb.net/test" --username <username>
错误:
error connecting to host: could not connect to server: server selection error: server
selection timeout, current topology: { Type: Single, Servers: [{ Addr: <clustername>-
<string(private?)>.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error:
connection() : dial tcp: lookup <clustername>-<string(private?)>.mongodb.net on 127.0.0.53:53: no such
host }, ] }
我已经尝试了所有我能想到的,这似乎是我能得到的最接近的。在我看来,我的连接字符串有误,但我不知道如何解决。我刚接触数据库,尤其是 MongoDB。非常感谢任何帮助。
注意:我在终端中 运行 而不是 mongo shell。导入工作在我的本地机器上使用相同的文件。
尝试从 mongoimport 中的 uri 中删除 ssl=true 参数,因为您正在命令中传递客户端和 ca 证书。
还有一个建议,在 uri 中使用集群的所有主机名。如果您的集群有多个节点,通常就是这种情况。
或者:
在 altas 页面中查找命令行工具。它作为 mongoimport 到集群的模板命令。
希望对您有所帮助。
点击展开按钮,然后点击命令行工具