配置用户和使用PHP连接到Mongo时遇到问题

I installed mongo 3.0.0 on my ubuntu server. I tried to use PHP (with appropriate lib installed) to connect to mongo to learn sth new. Unfortunaltey I cannot go any further. My user configuration looks like this:

> use testdb
switched to db testdb
> show users
{
    "_id" : "testdb.testdb",
    "user" : "testdb",
    "db" : "testdb",
    "roles" : [
        {
            "role" : "readWrite",
            "db" : "testdb"
        }
    ]
}

Then I try to execute the following PHP code:

try{
    $uri = "mongodb://testdb:password@xxx.xxx.xxx.xxx:27017/testdb";
    $options = array("connectTimeoutMS" => 30000);
    $client = new MongoClient($uri, $options );
}
catch(Exception $e) {
    echo 'Message: ' .$e->getMessage();
    die();
}
$db = $client->selectDB("testdb");

I get "Message: Failed to connect to: xxx.xxx.xxx.xxx:27017: Authentication failed on database 'testdb' with username 'testdb': auth failed".

In /etc/mongod.conf I have "auth = true" uncommented

I also verified the conncetion with:

> nc -w 3 -v xxx.xxx.xxx.xxx 27017 Connection to xxx.xxx.xxx.xxx 27017
> port [tcp/*] succeeded!

I dig through Internet, i spent few hours already on this, I even re-installed mongo and set everything up again without any success. Could you point to where to look for solution?

The authentication schema of 3.0 is not compatible with 2.x drivers. One way you should be able to make it work is by downgrading the authentication mechanism:

use "admin"
var schema = db.system.version.findOne({"_id" : "authSchema"})
schema.currentVersion = 3
db.system.version.save(schema)

Then create a user and you should be able to connect with it.