14

I just wanted to take a look at Mongo-DB. But i just don't get it running. I've installed it with 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?

Community
  • 1
  • 1
mr.alex
  • 503
  • 1
  • 8
  • 16
  • Which OS do you use? Can you connect to the server using the mongo command line client (on the same machine)? – VolkerK Jan 31 '10 at 21:00
  • I also cannot connect to mongodb but the error is this: Class 'Mongo' not found. Do you have an idea how to fix this? Thanks. – unpangloss Apr 08 '10 at 08:05

7 Answers7

17

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)

Mark Embling
  • 12,605
  • 8
  • 39
  • 53
  • 3
    Shame on me!!! :-) Exactly this was my Problem. Anyhow I thought the PHP-Extension would start the Daemon automatically, and I didn't even thought about that. Thanks for your Post! – mr.alex Feb 01 '10 at 12:08
8

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.

2

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 >

kannan
  • 21
  • 1
1

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

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
Hicham
  • 11
  • 1
1

custom string looks like that

mongodb://username:password@host:port/database
csgwro
  • 181
  • 2
  • 5
0

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...

HVKotak
  • 258
  • 5
  • 12
0

just write mongod in your terminal and will work well

SagarPPanchal
  • 9,839
  • 6
  • 34
  • 62