Codeigniter error Unable to connect to MongoDB: Failed to connect: auth failed
<p>I am trying to connect to a mongodb database 'exam' using codeigniter mongodb library Codeigniter-mongo-library-master. I have created an user for this db using </p>

<pre><code>db.createUser({ user: "root",
  pwd: "root",
  roles: [
    { role: "readWrite", db: "exam" },
   ]
}}
</code></pre>

<p>It was successful.</p>

<p>Then, when I tried to connect to this database in codeigniter using :</p>

<pre><code>$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';
</code></pre>

<p>I got an error as shown below:</p>

<blockquote>
  <p>Unable to connect to MongoDB: Failed to connect to: localhost:27017: Authentication failed on database 'exam' with username 'root': auth failed.</p>
</blockquote>

<p><strong>I am using php version 5.5.12 and mongodb driver php_mongo-1.5.1-5.5-vc11-x86_64.dll on Windows 7.</strong></p>

<p>Can I get some help in solving this problem?</p>