CodeIgniter错误:无法使用Mongodb数据库使用提供的设置连接到数据库服务器


CodeIgniter error : Unable to connect to your database server using the provided settings using Mongodb database

我正在尝试创建一个远程mongodb服务器来处理我的CodeIgniter项目。

我已经将我的mongodb conf文件更新为

// /etc/mongodb.conf
bind_ip = 0.0.0.0
port = 27017

当我在shell脚本中访问我的IP时,它运行良好。

~$ mongo --host 192.168.20.106

显示的结果:

MongoDB shell version: 2.4.9
connecting to: 192.168.20.106:27017/test
Server has startup warnings: 
Mon Nov  2 12:29:34.643 [initandlisten] 
Mon Nov  2 12:29:34.643 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Mon Nov  2 12:29:34.643 [initandlisten] **       32 bit builds are limited to less than 2GB of data (or less with --journal).
Mon Nov  2 12:29:34.643 [initandlisten] **       See http://dochub.mongodb.org/core/32bit
Mon Nov  2 12:29:34.643 [initandlisten] 

在我的另一台电脑192.168.20.107中,有一个名为ciprojectconfig/cimongo.php的CodeIgniter项目,我在下面添加了几行来连接远程主机服务器。

// Generally localhost
$config['host'] = "192.168.20.106";
// Generally 27017
$config['port'] = 27017;
// The database you want to work on
$config['db'] = "tank_auth";
// Required if Mongo is running in auth mode
$config['user'] = "";
$config['pass'] = "";
/*Defaults to FALSE. If FALSE, the program continues executing without waiting for a database response. If TRUE, the program will wait for the database response and throw a MongoCursorException if the update did not succeed.*/
$config['query_safety'] = TRUE;
//If running in auth mode and the user does not have global read/write then set this to true
$config['db_flag'] = TRUE;
//consider these config only if you want to store the session into mongoDB
//They will be used in MY_Session.php
$config['sess_use_mongo'] = TRUE;
$config['sess_collection_name'] = 'ci_sessions';

现在我想使用192.168.20.107/ciproject访问此应用程序当我在网上访问这个URL时,它显示错误

发生数据库错误

Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 1232

我已经尝试过了,但没有得到任何解决方案。

经过研究,在stackoverflow的帮助下,我找到了解决方案。

在congif/database.php中,只将其设为FALSE

$db['default']['db_debug'] = FALSE;

感谢stackoverflow参考链接:)