AuthenticationFailed:分片MongoDB上的用户文档中缺少MONGODB-CR凭据:无法连接到:queryrouter0.example.com:27017:

我有一个分片的MongoDB设置。</ p>

我正在尝试连接 来自我的Laravel应用程序</ p>

在我对数据库进行分片之前,我正在使用 laravel-mongodb 连接到我的常规mongodb实例。</ p>

这是我以前的配置</ p>

 'mongodb'=  &GT;  array(
'driver'=&gt;'mongodb',
'host'=&gt; env('MONGODB_HOST','localhost'),
'port'=&gt; env('MONGODB_PORT',27017),

'用户名'=&gt; env('MONGODB_USERNAME',''),
'密码'=&gt; env('MONGODB_PASSWORD',''),
'数据库'=&gt; env('MONGODB_DATABASE', ''),
'options'=&gt; array(
'db'=&gt; env('MONGODB_AUTHDATABASE','')//设置auth DB


</ code> < / pre>

我尝试将 MONGODB_HOST </ code>更新为分片查询路由器主机名,但我现在收到错误</ p>


< p> [MongoConnectionException]
无法连接到:queryrouter0.example.com:27017:使用用户名'maxrosecollins'对数据库'admin'进行身份验证失败:auth failed` </ p>
</ blockquote>

我可以在 queryrouter0.example.com </ code>服务器的日志中看到</ p>


2017-09-05T14:42:36.558+ 0000 I NETWORK [thread2]连接从45.32.144.169:3接受 3086#41615(1连接现已开放)
2017-09-05T14:42:36.560 + 0000我访问[conn41615]验证db:admin {authenticate:1,用户:“maxrosecollins”,nonce:“xxx”,密钥: “xxx”} </ p>

2017-09-05T14:42:36.562 + 0000 I ACCESS [conn41615]无法通过机制MONGODB-CR验证maxrosecollins @ admin:AuthenticationFailed:MONGODB-CR凭据丢失 在用户文档中</ p>

2017-09-05T14:42:36.563 + 0000 I - [conn41615]结束连接45.32.144.169:33086(1个连接现已打开)</ p>
</ blockquote>

我可以使用以下命令连接到查询路由器。
这是在同一台服务器上我使用laravel时获得auth失败错误。 我有双重检查密码和用户名</ p>

  mongo queryrouter0.example.com:27017 -u“maxrosecollins”-p“password”--authenticationDatabase“admin”
</ code > </ pre>
</ div>

展开原文

原文

I have a sharded MongoDB setup.

I'm trying to connect to it from my Laravel application

Before I sharded my database I was using laravel-mongodb to connect to my regular mongodb instance.

This was my previous config

'mongodb' => array(
        'driver'   => 'mongodb',
        'host'     => env('MONGODB_HOST', 'localhost'),
        'port'     => env('MONGODB_PORT', 27017),
        'username' => env('MONGODB_USERNAME', ''),
        'password' => env('MONGODB_PASSWORD', ''),
        'database' => env('MONGODB_DATABASE', ''),
        'options' => array(
            'db' => env('MONGODB_AUTHDATABASE', '') //Sets the auth DB
        )
    )

I tried to update the MONGODB_HOST to the sharded query router hostname but I am now getting the error

[MongoConnectionException] Failed to connect to: queryrouter0.example.com:27017: Authentication failed on database 'admin' with username 'maxrosecollins': auth failed`

I can see in the logs on the queryrouter0.example.com server

2017-09-05T14:42:36.558+0000 I NETWORK [thread2] connection accepted from 45.32.144.169:33086 #41615 (1 connection now open) 2017-09-05T14:42:36.560+0000 I ACCESS [conn41615] authenticate db: admin { authenticate: 1, user: "maxrosecollins", nonce: "xxx", key: "xxx" }

2017-09-05T14:42:36.562+0000 I ACCESS [conn41615] Failed to authenticate maxrosecollins@admin with mechanism MONGODB-CR: AuthenticationFailed: MONGODB-CR credentials missing in the user document

2017-09-05T14:42:36.563+0000 I - [conn41615] end connection 45.32.144.169:33086 (1 connection now open)

I can connect to the query router using the following. This is on the same server I am getting the auth failed error when using laravel. I have double checked passwords and usernames

mongo queryrouter0.example.com:27017 -u "maxrosecollins" -p "password" --authenticationDatabase "admin"

2个回答



我的 laravel-mongodb </ code>安装版本2不支持 SCRAM -SHA-1 </ code>身份验证机制。</ p>

我使用 composer update </ code>升级到版本3,这也意味着要升级php mongo适配器 其他依赖项。</ p>

然后我运行 db.adminCommand({authSchemaUpgrade:1}); </ code> 请参阅升级身份验证 </ p>

此后我可以使用我的mongo查询路由器进行身份验证</ p >
</ div>

展开原文

原文

I worked out my laravel-mongodb install was version 2 which doesn't support the SCRAM-SHA-1 authentication mechanism.

I used composer updateto upgrade to version 3 which also meant upgrading the php mongo adapter along with a lot of other dependencies.

I then ran db.adminCommand({authSchemaUpgrade: 1}); see upgrading auth

After this I could authenticate with my mongo query router



 'connections'=&gt;  [
'ongodb'=&gt; [
'driver'=&gt; 'mongodb',
'dsn'=&gt; “mongodb的://用户:password@xxx-shard-00-00-uggj0.mongodb.net:27017,xxx-shard-00-01-uggj0.mongodb.net:27017,XXX-碎片-00-02-uggj0 .mongodb.net:27017 / homestead?ssl = true&amp; replicaSet = xxx-shard-0&amp; authSource = admin',
'database'=&gt; 'homestead',

],
</ code> </ pre>

我可以像这样连接到我的云图集</ p>
</ div>

展开原文

原文

'connections' => [
     'mongodb' => [
      'driver'   => 'mongodb',
      'dsn' => 'mongodb://User:password@xxx-shard-00-00-uggj0.mongodb.net:27017,xxx-shard-00-01-uggj0.mongodb.net:27017,xxx-shard-00-02-uggj0.mongodb.net:27017/homestead?ssl=true&replicaSet=xxx-shard-0&authSource=admin',
      'database' => 'homestead',

  ],

i can connect like this to my cloud atlas

doupixian1436
doupixian1436 我不应该连接到查询路由器而不是分片?
大约 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问