mongodb service in PHP
I'm trying to connect to mongodb in php. There's no problem if mongodb is start in shell with mongod command.
new Mongo("mongodb://".$_host.":".$_port,true)
But when i start mongodb server as a service, i can connect with the mongo command, but i cant connect in php.
new Mongo("mongodb://".$_host.":".$_port,true)
Is there any 开发者_运维百科other arguments? I'm using the last version of mongodb and the last version of php.
Can someone help me?
What are your command line parameters for the MongoDB service? Is it possible that you've specified a different configuration than what you get by default when manually running mongod? What parameters did you use to install MongoDB as a service?
Thanks for your answer and comment, i fix it.
The problem was in the service command line , i use this command
"C:\mongodb\bin\mongod" --bind_ip 127.0.0.1 --logpath "C:\data\db\mongodb.log" --logappend --dbpath "C:\data\db" --port 27100 --install
instead of
"C:\mongodb\bin\mongod" --bind_ip myIPadress --logpath "C:\data\db\mongodb.log" --logappend --dbpath "C:\data\db" --port 27100 --install
In the php code new Mongo("mongodb://".$_host.":".$_port,true)
, $host = myIPadress
That why it was working in command line and not in the php code, it must be the same IPadress, don't use localhost or something like that if you don't use a default new Mongo()
精彩评论