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}
有人能解决这个问题吗? Tkx!
答案 0 :(得分: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 book。