开发者

Can't connect to MongoDB through PHP

I just wanted to take a look at Mongo-DB. But i just don't get it running. I've installed it wit开发者_开发问答h PECL and my phpinfo() tells me that the extension is loaded, but when i try to get a connection with

$mongo = new Mongo();

I get this:

Fatal error: Uncaught exception 'MongoConnectionException' with message ': Transport endpoint is not connected'

Anybody have the same Problem? ... Or any Idea on this?


Please don't take this the wrong way, but have you actually got the server running? Only it looks like your error relates to a failure to connect and you've made no mention of the server or where it is located (localhost on the default port for example)


any server start method, such as "/etc/init.d/mongodb start" or "service start mongodb" will fail, if a stale lock file still exists. In Ubuntu/Debian this is /var/lib/mongodb/mongod.lock. Look for this and delte it, if it exists and seems to be an old one.


check out whether server is running or not..

/etc/init.d/mongodb start

then go to

root@kannan-desktop:~# mongo MongoDB shell version: 1.6.3 connecting to: test >


Don't forget to change the IP in your mongod.conf if it's a new installation.


custom string looks like that

mongodb://username:password@host:port/database


First Change the Default db path by following command

$ sudo mkdir -p /data/db/

$ sudo chown id -u /data/db

and then the final command is..

$ mongod --journal

Do not close terminal until you are working with mongoDB

It works for me...


just write mongod in your terminal and will work well

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜