php - Codeigniter error Unable to connect to MongoDB: Failed to connect: auth failed -


i trying connect mongodb database 'exam' using codeigniter mongodb library codeigniter-mongo-library-master. have created user db using

db.createuser({ user: "root",   pwd: "root",   roles: [     { role: "readwrite", db: "exam" },    ] }} 

it successful.

then, when tried connect database in codeigniter using :

$config['mongo_db']['default']['no_auth'] = false; $config['mongo_db']['default']['hostname'] = 'localhost'; $config['mongo_db']['default']['port'] = '27017'; $config['mongo_db']['default']['username'] = 'root'; $config['mongo_db']['default']['password'] = 'root'; $config['mongo_db']['default']['database'] = 'exam'; 

i got error shown below:

unable connect mongodb: failed connect to: localhost:27017: authentication failed on database 'exam' username 'root': auth failed.

i using php version 5.5.12 , mongodb driver php_mongo-1.5.1-5.5-vc11-x86_64.dll on windows 7.

can in solving problem?

now open controller or model file, need database connection active , write below code in constructor of class.

$this->load->library('mongo_db', array('activate'=>'newdb'),'mongo_db2');


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -