我正在尝试将 bake 与 cakephp 一起使用。我已经到了下面的蛋糕欢迎屏幕:
Welcome to CakePHP v2.3.0-RC2 Console
---------------------------------------------------------------
App : app
Path: /Users/philip7899/Desktop/Philips Server 2/blog/app/
---------------------------------------------------------------
Interactive Bake Shell
---------------------------------------------------------------
[D]atabase Configuration
[M]odel
[V]iew
[C]ontroller
[P]roject
[F]ixture
[T]est case
[Q]uit
What would you like to Bake? (D/M/V/C/P/F/T/Q)
我输入 C,它会询问我的数据库配置:
Bake Controller
Path: /Users/philip7899/Desktop/Philips Server 2/blog/app/Controller/
---------------------------------------------------------------
Use Database Config: (default/test)
[default] >
我按 Enter 确认使用“默认”数据库配置。我已将其粘贴在下面:
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => 'root',
'database' => 'cakephp_blog',
'prefix' => '',
//'encoding' => 'utf8',
);
然后我收到以下错误:
Warning Error: PDO::__construct(): [2002] No such file or directory
(trying to connect via unix:///var/mysql/mysql.sock) in
[/Users/philip7899/Desktop/Philips Server 2/blog/lib/Cake/Model/Datasource/Database/Mysql.php, line 157]
Error: Database connection "Mysql" is missing, or could not be created.
#0 /Users/philip7899/Desktop/Philips Server 2/blog/lib/Cake/Model/Datasource/DboSource.php(261): Mysql->connect()
#1 /Users/philip7899/Desktop/Philips Server 2/blog/lib/Cake/Model/ConnectionManager.php(101): DboSource->__construct(Array)
#2 /Users/philip7899/Desktop/Philips Server 2/blog/lib/Cake/Console/Command/Task/ModelTask.php(903): ConnectionManager::getDataSource('default')
#3 /Users/philip7899/Desktop/Philips Server 2/blog/lib/Cake/Console/Command/Task/ControllerTask.php(396): ModelTask->getAllTables('default')
#4 /Users/philip7899/Desktop/Philips Server 2/blog/lib/Cake/Console/Command/Task/ControllerTask.php(419): ControllerTask->listAll(NULL)
#5 /Users/philip7899/Desktop/Philips Server 2/blog/lib/Cake/Console/Command/Task/ControllerTask.php(136): ControllerTask->getName()
#6 /Users/philip7899/Desktop/Philips Server 2/blog/lib/Cake/Console/Command/Task/ControllerTask.php(61): ControllerTask->_interactive()
#7 /Users/philip7899/Desktop/Philips Server 2/blog/lib/Cake/Console/Command/BakeShell.php(113): ControllerTask->execute()
#8 /Users/philip7899/Desktop/Philips Server 2/blog/lib/Cake/Console/Shell.php(391): BakeShell->main()
#9 /Users/philip7899/Desktop/Philips Server 2/blog/lib/Cake/Console/ShellDispatcher.php(199): Shell->runCommand(NULL, Array)
#10 /Users/philip7899/Desktop/Philips Server 2/blog/lib/Cake/Console/ShellDispatcher.php(67): ShellDispatcher->dispatch()
#11 /Users/philip7899/Desktop/Philips Server 2/blog/app/Console/cake.php(33): ShellDispatcher::run(Array)
#12 {main}
在过去的几个小时里,我一直在搜索互联网并试图解决这个问题,但我无法修复它。我知道数据库配置正在运行,因为网站本身运行良好。我怎样才能让蛋糕在控制台中工作并让我继续?谢谢。