简体   繁体   English

无法使用锂连接到mongoDB

[英]Can't connect to mongoDB with lithium

I have uncomented mongodb connection in bootstrap/connections.php and everything seems to be ok but now I'm getting following error: 我在bootstrap / connections.php中没有启用mongodb连接,一切似乎都没问题,但现在我遇到了以下错误:

( ! ) Fatal error: Uncaught exception 'lithium\core\NetworkException' with message 'Could not connect to the database.' in C:\wamp\www\libraries\lithium\data\source\MongoDb.php on line 792
    ( ! ) lithium\core\NetworkException: Could not connect to the database. in C:\wamp\www\libraries\lithium\data\source\MongoDb.php on line 792
    Call Stack
    #   Time    Memory  Function    Location
    1   0.0004  370296  {main}( )   ..\index.php:0
    2   0.0328  2618640 lithium\action\Dispatcher::run( )   ..\index.php:36
    3   0.0328  2619848 lithium\core\StaticObject::_filter( )   ..\Dispatcher.php:122
    4   0.0329  2621472 lithium\util\collection\Filters::run( ) ..\StaticObject.php:128
    5   0.0330  2623800 {closure}( )    ..\Filters.php:182
    6   0.0397  2692456 lithium\util\collection\Filters->next( )    ..\cache.php:47
    7   0.0397  2692488 {closure}( )    ..\Filters.php:201
    8   0.0428  2720784 lithium\util\collection\Filters->next( )    ..\action.php:52
    9   0.0428  2720816 lithium\action\{closure}( ) ..\Filters.php:201
    10  0.0448  2756432 lithium\core\StaticObject::invokeMethod( )  ..\Dispatcher.php:121
    11  0.0448  2756464 lithium\action\Dispatcher::_call( ) ..\StaticObject.php:74
    12  0.0449  2757552 lithium\core\StaticObject::_filter( )   ..\Dispatcher.php:203
    13  0.0449  2757808 lithium\action\{closure}( ) ..\StaticObject.php:121
    14  0.0449  2757808 lithium\action\Controller->__invoke( )  ..\Dispatcher.php:200
    15  0.0449  2759408 lithium\core\Object->_filter( ) ..\Controller.php:184
    16  0.0449  2759688 lithium\action\{closure}( ) ..\Object.php:245
    17  0.0450  2759936 lithium\core\Object->invokeMethod( )    ..\Controller.php:172
    18  0.0450  2759968 app\controllers\PostsController->add( ) ..\Object.php:167
    19  0.0643  3862976 lithium\data\entity\Document->save( )   ..\PostsController.php:25
    20  0.0643  3863176 lithium\data\Entity->__call( )  ..\Entity.php:0
    21  0.0644  3863672 call_user_func_array ( )    ..\Entity.php:197
    22  0.0644  3863936 lithium\data\Model->save( ) ..\Entity.php:0
    23  0.0644  3867352 lithium\data\Model::_filter( )  ..\Model.php:719
    24  0.0645  3867608 lithium\core\StaticObject::_filter( )   ..\Model.php:891
    25  0.0645  3867728 lithium\data\{closure}( )   ..\StaticObject.php:121
    26  0.0723  4182168 lithium\data\source\MongoDb->create( )  ..\Model.php:713
    27  0.0723  4182168 lithium\data\source\MongoDb->_checkConnection( )    ..\MongoDb.php:346

Seems kinda weird issue for me. 对我来说似乎有点奇怪。 To be exact was following lithium blog tutorial. 确切地说是关注锂博客教程。

EDIT adding mongo db configuration from phpinfo() 编辑从phpinfo()添加mongo db配置

mongo
MongoDB Support enabled
Version     1.1.3

Directive   Local Value Master Value
mongo.allow_empty_keys  0   0
mongo.allow_persistent  1   1
mongo.auto_reconnect    1   1
mongo.chunk_size    262144  262144
mongo.cmd   $   $
mongo.default_host  localhost   localhost
mongo.default_port  27017   27017
mongo.long_as_object    0   0
mongo.native_long   0   0
mongo.no_id 0   0
mongo.utf8  1   1

Make sure you're running the latest Git master of Lithium. 确保你正在运行最新的Git master of Lithium。 The last release version was 0.9.9, and the Mongo PECL extension has made 3 major BC-breaking changes since then. 最后一个版本是0.9.9,并且Mongo PECL扩展已经进行了3次主要的BC破坏性更改。 They're fixed in the core, they just haven't been rolled into a release yet. 它们已经固定在核心中,它们还没有被发布到版本中。 Also, a user name and password are NOT mandatory. 此外,用户名和密码不是必需的。

Assuming you have correct host, port and login info make sure you have the newest version on MongoDb extension. 假设您拥有正确的主机,端口和登录信息,请确保您拥有MongoDb扩展的最新版本。

I had similar problem. 我有类似的问题。 Li3 uses mongodb://{$login}{$host}/{$cfg['database']} which wasn't supported by the older versions. Li3使用旧版本不支持的mongodb://{$login}{$host}/{$cfg['database']}

maybe it's this ticket (solved it for me): 也许是这张票(为我解决了):

http://rad-dev.org/lithium/tickets/view/204 http://rad-dev.org/lithium/tickets/view/204

我不得不降级我的PECL扩展以使其正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM