我是PHP新手,在Ruby中擁有堅實的基礎,只是試圖讓CakePHP應用程序啓動並運行。由於職業原因,我正在使用舊版本 - 版本1.3。不幸的是升級不是解決這個問題的一個選擇。蛋糕PHP 1.3 - 新應用程序,無法連接到數據庫,php_network_getaddresses/nodename和服務名稱
這就是說,我很樂意讓我的數據庫全部建立起來。
我的錯誤:
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
線82-87從app/webroot/index.php
:
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',
);
}
?>
我已經看了很多這方面的解決方案,大多數似乎與CakePHP的後續版本有關。任何幫助都是極好的。
謝謝!
是'dumpbox_host'一個有效的MySQL主機您的服務器可以解決?即如果您要從命令行手動連接,例如'mysql -h'dumpbox_host'-u'root'-p'password''my_test_db''它工作嗎? – 2015-03-30 23:57:59
爲什麼要在1.3上構建一個新的應用程序? Cake現在在3.0。如果沒有別的,至少去2.x.這是非常類似的代碼。 – Dave 2015-03-30 23:59:26