我正在尝试创建一个远程mongodb服务器来处理我的CodeIgniter项目。
我已将我的mongodb配置文件更新为
// /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]
IN我的另一台PC 192.168.20.107有CodeIgniter项目名为 ciproject config / cimongo.php我在下面的行中添加了与远程主机服务器连接。
// 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访问此应用程序 当我在网站上访问此网址时显示错误
发生数据库错误
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 1232
我已经尝试this但没有得到任何解决方案。
答案 0 :(得分:0)
只是将其设为FALSE
$db['default']['db_debug'] = FALSE;
感谢stackoverflow Ref Link:)