cakeCake PHP 1.3–新应用程序,无法连接到DB,提供PHP_network_getaddresses/no


cakeCake PHP 1.3 – New app, not able to connect to DB, php_network_getaddresses / nodename nor servname provided

我是PHP新手,在Ruby方面有着坚实的基础,只是想让Cake PHP应用程序启动并运行。出于专业原因,我使用的是旧版本1.3。不幸的是,升级并不是解决这个问题的一种选择。

也就是说,我很想得到一些帮助来设置我的数据库。

我的错误:

Warning (2): mysql_connect() [function.mysql-connect]: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 561]

堆叠竞赛:

mysql_connect - [internal], line ??
DboMysql::connect() - CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 561
DboSource::__construct() - CORE/cake/libs/model/datasources/dbo_source.php, line 143
ConnectionManager::getDataSource() - CORE/cake/libs/model/connection_manager.php, line 114
include - APP/views/pages/home.ctp, line 77
View::_render() - CORE/cake/libs/view/view.php, line 736
View::render() - CORE/cake/libs/view/view.php, line 431
Controller::render() - CORE/cake/libs/controller/controller.php, line 909
PagesController::display() - CORE/cake/libs/controller/pages_controller.php, line 83
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 86

来自app/webroot/index.php:的82-87线

if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
        return;
    } else {
        $Dispatcher = new Dispatcher();
        $Dispatcher->dispatch(); /* line 86 */
    }

如果需要,我的database.php文件如下所示:

<?php
class DATABASE_CONFIG {
    var $default = array(
        'driver' => 'mysql',
        'persistent' => false,
        'host' => 'dumpbox_host',
        'port' => 8889,
        'login' => 'root',
        'password' => 'password',
        'database' => 'my_test_db',
    );
}
?>

我已经为此研究了许多解决方案,其中大多数似乎与Cake PHP的后续版本有关。任何帮助都会很棒。

谢谢!

PHP无法解析数据库的主机名"dumpbox_host"。如果您的数据库托管在本地,只需使用"localhost"。

如果您的服务器是linux风格的,请编辑/etc/hosts并为"dumpbox_host"添加适当的IP。否则,您可以直接将主机名更改为您知道有效的主机名。

如果您在Windows上,您可以将名称添加到C:''Windows''System32''drivers''etc''hosts