dry18813 2015-11-02 09:28
浏览 71

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

I am trying to create a remote mongodb server to work with on my CodeIgniter project.

I have updated my mongodb conf file to

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

When I access my IP in shell script it working fine.

~$ mongo --host 192.168.20.106

Result Shown:

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 My another PC 192.168.20.107 has CodeIgniter project called ciproject config/cimongo.php I added below lines to connect with the remote host server.

// 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';

Now I want to access this application by using the 192.168.20.107/ciproject When I access this URL in web its show me error

A Database Error Occurred

Unable to connect to your database server using the provided settings.

Filename: core/Loader.php

Line Number: 1232

I Already Try this but not getting any solution.

  • 写回答

1条回答 默认 最新

  • dsdzz04802 2015-11-03 06:12
    关注

    after done with research and with the help of stackoverflow I found solution.

    in congif/database.php just make it as FALSE

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

    Thanks stackoverflow Ref Link:)

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算