1

当我尝试使用蛋糕控制台时,我遇到了一些麻烦。我在Windows 7上。尝试做蛋糕烘焙模型时,出现以下错误:

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}

有人可以解决这个问题吗?咳咳!

4

1 回答 1

0

看起来您没有定义数据库设置。
在 中定义您的数据库连接app/config/Database.php

它大致如下所示。
(请记住至少为您的设置更新login,password和)database

<?php
public $default = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => 'localhost',
    'port' => '',
    'login' => 'YOUR MYSQL USERNAME',
    'password' => 'YOUR MYSQL PASSWORD',
    'database' => 'YOUR DATABASE NAME',
    'schema' => '',
    'prefix' => '',
    'encoding' => ''
);

如果您需要一些指导,请参阅这本CakePHP 书。

于 2012-07-25T15:52:20.527 回答