问题
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?
回答1:
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)
回答2:
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.
回答3:
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 >
回答4:
Don't forget to change the IP in your mongod.conf
if it's a new installation.
回答5:
custom string looks like that
mongodb://username:password@host:port/database
回答6:
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...
回答7:
just write mongod
in your terminal and will work well
来源:https://stackoverflow.com/questions/2173155/cant-connect-to-mongodb-through-php