【问题标题】:Error: Could not connect to a host in Mongo DB错误:无法连接到 Mongodb 中的主机
【发布时间】:2020-10-01 04:40:42
【问题描述】:

我正在尝试在我在 Mongo Db Atlas 中创建的 MongoDB 集合事务中导入 CSV 数据文件。

我使用了以下连接字符串: ''' 'mongoimport --uri "mongodb+srv://username:password@reportingdata-n8b3j.mongodb.net/ecommerce?retryWrites=true&w=majority" --collection transactions --drop --type csv --headerline --file data .csv'' ''' 它显示以下错误: '''

2020-06-11T19:28:03.513+0545 警告:忽略不受支持的 URI 参数“retrywrites” 2020-06-11T19:28:05.849+0545 连接到主机时出错:无法连接到服务器:connection():身份验证错误:sasl 对话错误:无法使用机制“SCRAM-SHA-1”进行身份验证:(AtlasError)身份验证失败的。 '''

我目前使用的是 mongo db 4.2

【问题讨论】:

  • 我收到了unable to authenticate using mechanism "SCRAM-SHA-1" 消息。我不确定究竟是什么修复了它,但在 Atlas 上更改我的密码后,一切似乎都很好。

标签: mongodb


【解决方案1】:

尝试使用此命令,对我有用(您可以在命令行工具中找到该命令)还检查您的 IP 是否在白名单中,添加您当前的 IP。

mongoimport --host atlas-1jjmob-shard-0/reportingdata-shard-00-00.66vlq.mongodb.net:27017,reportingdata-shard-00-01.66vlq.mongodb.net:27017,reportingdata-shard-00-02.66vlq.mongodb.net:27017 --ssl --username admin --password <password> --authenticationDatabase admin --db ecommerce --collection transactions --drop --type csv --headerline --file data.csv

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-03
    • 2023-03-05
    • 1970-01-01
    • 2016-08-06
    相关资源
    最近更新 更多