Mongodb数据库上的SASL身份验证失败

编程入门 行业动态 更新时间:2024-10-28 05:24:09
本文介绍了Mongodb数据库上的SASL身份验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在尝试使用PHP Mongodb驱动程序连接到Mongodb时遇到问题.

I-m having an issue trying connect to Mongodb using PHP Mongodb driver.

实际上,我有一个名为LRS的数据库,并且我的设置文件中有一个名为"juano"的用户,其密码为pwd:"12345",我确定我编写了正确的配置. 但是,当我在Laravel中加载主页时,会收到以下消息:

Actually I have a database called LRS and it has a user called "juano" with a pwd:"12345" in my settings file I-m sure that I wrote the correct configuration. But when I load my homepage in Laravel I receive this message:

MongoConnectionException (71) HELP Failed to connect to: localhost:27017: SASL Authentication failed on database'LRS': Authentication failed.

更具体的错误在这里找到

More specific the error found here

if (isset($config['password']) && $config['password']) { $options['password'] = $config['password']; } return new MongoClient($dsn, $options); }

这是我的配置文件

<?php return [ 'connections' => [ 'mongodb' => [ 'driver' => 'mongodb', 'host' => 'localhost', 'port' => 27017, 'username' => 'juano', 'password' => '12345', 'database' => 'LRS' ], ] ];

推荐答案

对不起,我感到很愚蠢,因为问题是我在本地计算机上启动mongod,然后将我的网站运行到虚拟机中. 因此,在我的数据库连接配置文件中,我在服务器字段中写了"localhost".

Sorry guys, I-m feel stupid because the problem was I started mongod in my local machine and then I ran my web into a Virtual Machine. So, in my database connection config file I wrote "localhost" in the server field.

更多推荐

Mongodb数据库上的SASL身份验证失败

本文发布于:2023-10-13 00:38:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1486316.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:身份验证   数据库   Mongodb   SASL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!