>  기사  >  백엔드 개발  >  mysql - php连接MongoDB总是失败,为什么?

mysql - php连接MongoDB总是失败,为什么?

WBOY
WBOY원래의
2016-06-06 20:11:591864검색

mysql - php连接MongoDB总是失败,为什么?

用db.getMongo();得到的是:127.0.0.1

浏览器中访问:http://127.0.0.1:27017/
得到的是:It looks like you are trying to access MongoDB over HTTP on the native driver port.

但执行下面的代码:
// 连接到mongodb
$m = new MongoClient();
echo "Connection to database successfully";
// 选择一个数据库
$db = $m->mydb;
echo "Database mydb selected";
?>

结果是:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at admin@phpStudy.net to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

为什么会这样?

回复内容:

mysql - php连接MongoDB总是失败,为什么?

用db.getMongo();得到的是:127.0.0.1

浏览器中访问:http://127.0.0.1:27017/
得到的是:It looks like you are trying to access MongoDB over HTTP on the native driver port.

但执行下面的代码:
// 连接到mongodb
$m = new MongoClient();
echo "Connection to database successfully";
// 选择一个数据库
$db = $m->mydb;
echo "Database mydb selected";
?>

结果是:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at admin@phpStudy.net to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

为什么会这样?

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.