0

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.

Community
  • 1
  • 1
Mukesh S
  • 367
  • 5
  • 19
  • you have to define this in `databse.php` – Abdulla Nilam Nov 02 '15 at 09:33
  • I have Downloaded this libraries from here https://docs.mongodb.org/ecosystem/drivers/php-libraries/ so its default they have provided but I want to use the mongodb as remove server and it can be accessible to the other member system as well by uing IP – Mukesh S Nov 02 '15 at 09:40
  • your url is wrong. check and post. i can check that – Abdulla Nilam Nov 02 '15 at 09:43
  • I edited please check – Mukesh S Nov 02 '15 at 09:44
  • Read this http://w3code.in/2015/10/how-to-connect-mongodb-with-codeigniter/ – Ricky Nov 02 '15 at 09:48
  • Thanks @Ricky but I was using this previously but some of the mongo array and sub array function was not working properly and I have to update with the cursor & extras featured for mongo So I use the latest version of librariy – Mukesh S Nov 02 '15 at 09:56

1 Answers1

0

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:)

Community
  • 1
  • 1
Mukesh S
  • 367
  • 5
  • 19