简体   繁体   English

XAMPP PHP和Mongo DB连接验证在数据库管理员上失败

[英]XAMPP PHP and Mongo DB connection authentication failed on database admin

I am a beginner in PHP and i am looking forward to make a connection from XAMPP php (local machine) and Mongo DB(remote machine). 我是PHP的初学者,我期待与XAMPP php(本地计算机)和Mongo DB(远程计算机)建立连接。 Please find the details below. 请在下面找到详细信息。

Note: I have already setup the mongo db extension and added the .dll file. 注意:我已经设置了mongo db扩展名并添加了.dll文件。 <?php $m = new MongoClient("mongodb://prizmaUser:Si$ney12#@10.xxx.xxx.238:27017"); ?>

And the result i am getting is 我得到的结果是

'Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: 10.xxx.xxx.238:27017: SASL Authentication failed on database 'admin': Authentication failed.' '致命错误:未捕获的异常'MongoConnectionException',消息为'无法连接至:10.xxx.xxx.238:27017:数据库'admin'的SASL身份验证失败:身份验证失败。 in C:\\xampp\\htdocs\\Testdata\\Simplification.php:61 Stack trace: #0 ' 在C:\\ xampp \\ htdocs \\ Testdata \\ Simplification.php:61堆栈跟踪中:#0'

I tried to using single quotes to escape the special characters in password field. 我尝试使用单引号将密码字段中的特殊字符转义。 Stil iam getting error. Stil Iam出错。 Any help would be highly appreciated.!!!! 任何帮助将不胜感激。

The error says 'Authentication failed on database 'admin': Authentication failed.', which means the user prizmaUser with password Si$ney12# does not exist in the admin database. 该错误显示“数据库'admin'上的身份验证失败:身份验证失败。”,这意味着在管理员数据库中不存在密码为Si $ ney12#的用户prizmaUser。 This means that the user was created in a specific database. 这意味着用户是在特定数据库中创建的。 Suppose that your database name is testdb, your connection should be 假设您的数据库名称为testdb,则您的连接应为

$m = new MongoClient('mongodb://prizmaUser:Si$ney12#@10.xxx.xxx.238:27017/testdb', array('authSource' => 'testdb'));

如果存在“ net:bindIp:0.0.0.0”,请检查您的mongo.conf。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM