FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Problem with PHP Driver Authentication
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Problem with PHP Driver Authentication [message #179128] Fri, 14 September 2012 08:20 Go to next message
picc09 is currently offline  picc09
Messages: 1
Registered: September 2012
Karma: 0
Junior Member
Hi,
I have a problem in the mongo's config on my computer that I use for local test.

-- mongodb.conf --
dbpath = /path/to/data
logpath = /path/to/mongo.log
logappend = true
auth = true

-- startup command --
sudo mongod -f /path/to/mongodb.conf --fork

I also tried:

sudo mongod -f /path/to/mongodb.conf --fork --auth

-- computer installation --
OSX 10.7.4
PHP 5.3.14 (ZendServerCE 5.6)
Mongo 2.2.0
PHP Mongo Driver: 1.2.12

-- php file that works but deprecated --
$mongo = new Mongo('mongodb://127.0.0.1:27017');
$db = $mongo->db_name;
$db->authenticate('user','pass');

-- new version of the code that does not work --
$mongo = new Mongo('mongodb://user:pass(at)127(dot)0(dot)0(dot)1:27017/db_name');
$db = $mongo->db_name;

throws exception:

MongoConnectionException: Couldn't authenticate with database db_name: username [user] in ...

Why?
What's wrong?
MongoHub working properly, mongo console is working properly, why PHP throws an exception?

Thanks in advance!

A.
Re: Problem with PHP Driver Authentication [message #179136 is a reply to message #179128] Fri, 14 September 2012 14:21 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 9/14/2012 4:20 AM, picc09(at)gmail(dot)com wrote:
> Hi,
> I have a problem in the mongo's config on my computer that I use for local test.
>
> -- mongodb.conf --
> dbpath = /path/to/data
> logpath = /path/to/mongo.log
> logappend = true
> auth = true
>
> -- startup command --
> sudo mongod -f /path/to/mongodb.conf --fork
>
> I also tried:
>
> sudo mongod -f /path/to/mongodb.conf --fork --auth
>
> -- computer installation --
> OSX 10.7.4
> PHP 5.3.14 (ZendServerCE 5.6)
> Mongo 2.2.0
> PHP Mongo Driver: 1.2.12
>
> -- php file that works but deprecated --
> $mongo = new Mongo('mongodb://127.0.0.1:27017');
> $db = $mongo->db_name;
> $db->authenticate('user','pass');
>
> -- new version of the code that does not work --
> $mongo = new Mongo('mongodb://user:pass(at)127(dot)0(dot)0(dot)1:27017/db_name');
> $db = $mongo->db_name;
>
> throws exception:
>
> MongoConnectionException: Couldn't authenticate with database db_name: username [user] in ...
>
> Why?
> What's wrong?
> MongoHub working properly, mongo console is working properly, why PHP throws an exception?
>
> Thanks in advance!
>
> A.
>


Did you ask in Mongo support? They know their code better than anyone else.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Never log deprecation warnings
Next Topic: log of all php's connection
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 15:12:47 GMT 2024

Total time taken to generate the page: 0.02367 seconds