cakephp2をインストールし、cakeコマンドでbakeする時にデータベースを選択した後大量のエラーが発生した。

Use Database Config: (test/default) 
[test] > 
Error: Database connection "Mysql" is missing, or could not be created.
#0 /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/lib/Cake/Model/Datasource/DboSource.php(278): Mysql->connect()
#1 /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/lib/Cake/Model/ConnectionManager.php(105): DboSource->__construct(Array)
#2 /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/lib/Cake/Console/Command/Task/ModelTask.php(956): ConnectionManager::getDataSource('test')
#3 /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/lib/Cake/Console/Command/Task/ModelTask.php(893): ModelTask->getAllTables('test')
#4 /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/lib/Cake/Console/Command/Task/ModelTask.php(983): ModelTask->listAll(NULL)
#5 /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/lib/Cake/Console/Command/Task/ModelTask.php(203): ModelTask->getName()
#6 /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/lib/Cake/Console/Command/Task/ModelTask.php(91): ModelTask->_interactive()
#7 /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/lib/Cake/Console/Command/BakeShell.php(109): ModelTask->execute()
#8 /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/lib/Cake/Console/Shell.php(462): BakeShell->main()
#9 /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/lib/Cake/Console/ShellDispatcher.php(222): Shell->runCommand(NULL, Array)
#10 /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/lib/Cake/Console/ShellDispatcher.php(66): ShellDispatcher->dispatch()
#11 /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/app/Console/cake.php(47): ShellDispatcher::run(Array)
#12 {main}
(base) kandadaisukenoMacBook-puro:app kandadaisuke$ sudo /Applications/MAMP/htdocs/XXXXXXXXXXXXXX/app/Console/cake bake

DB接続エラーが殆どなので、接続情報を調べる。

今回の場合は、database.phpの設定で接続先が間違っていたためエラーが起きていた。