我使用控制台烘焙了一个应用程序,从 URL 看起来一切正常。但是当我想在应用程序文件夹中烘焙模型时,出现错误:
Error: Database connection "Mysql" is missing, or could not be created.
#0 /opt/lampp/cake/lib/Cake/Model/ConnectionManager.php(98): DboSource->__construct(Array)
#1 /opt/lampp/cake/lib/Cake/Console/Command/Task/ModelTask.php(837): ConnectionManager::getDataSource('default')
#2 /opt/lampp/cake/lib/Cake/Console/Command/Task/ModelTask.php(782): ModelTask->getAllTables(NULL)
#3 /opt/lampp/cake/lib/Cake/Console/Command/Task/ModelTask.php(863): ModelTask->listAll(NULL)
#4 /opt/lampp/cake/lib/Cake/Console/Command/Task/ModelTask.php(186): ModelTask->getName()
#5 /opt/lampp/cake/lib/Cake/Console/Command/Task/ModelTask.php(84): ModelTask->_interactive()
#6 /opt/lampp/cake/lib/Cake/Console/Command/BakeShell.php(102): ModelTask->execute()
#7 /opt/lampp/cake/lib/Cake/Console/Shell.php(375): BakeShell->main()
#8 /opt/lampp/cake/lib/Cake/Console/ShellDispatcher.php(177): Shell->runCommand(NULL, Array)
#9 /opt/lampp/cake/lib/Cake/Console/ShellDispatcher.php(69): ShellDispatcher->dispatch()
#10 /opt/lampp/cake/lib/Cake/Console/cake.php(24): ShellDispatcher::run(Array)
#11 {main}
这就是我的 opt/lampp/htdocs/cakapp/Confg/database.php
<?php
class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => '127.0.0.1',
'login' => 'root',
'password' => 'alpha',
'database' => 'cakedb',
);
}
我的 php --ini 返回:
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File: /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed: /etc/php5/cli/conf.d/pdo.ini
而 phpinfo() 给我这个路径:
Configuration File (php.ini) Path: /opt/lampp/etc
Loaded Configuration File :/opt/lampp/etc/php.ini
上面两个输出是不是有矛盾?我的意思是 php --ini 应该输出 xampp 的 php.ini 而不是另一个,我怎样才能让它指向 xampp 的 php.ini?我试图通过用这条线改变 .bashrc 来改变它,当然没有帮助
export PATH=/opt/lampp/bin:$PATH
我尝试将此行添加到 database.configuration 文件中:'port' => '/opt/lampp/var/mysql/mysql.sock' 但它没有帮助。
我确实发现了一些类似的问题,但它们要么适用于 mac osx 的 windows,要么适用于 ubuntu。