我已经检查了有关我的问题的其他问题和答案,但似乎没有任何帮助解决它。
我正在使用安装了灯的 vagrant percise64(ubuntu 服务器 12.04)。在我的主机(桌面)上,我有 myfinalproject 目录,其中包含提取的 cakePHP 版本 2.3.5。我已经设置了所有 cakePHP 所需的内容,并且在 cakePHP 生成的页面上显示“Cake 能够连接到数据库”。
当我尝试烘焙新的模型/控制器或全部时,我收到以下错误:
Welcome to CakePHP v2.3.5 Console
---------------------------------------------------------------
App : app
Path: /home/shahar/development/myfinalproject/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)
> m
---------------------------------------------------------------
Bake Model
Path: /home/shahar/development/myfinalproject/app/Model/
---------------------------------------------------------------
Use Database Config: (default/test)
[default] > default
Error: Database connection "Mysql" is missing, or could not be created.
#0 /home/shahar/development/myfinalproject/lib/Cake/Model/ConnectionManager.php(107): DboSource->__construct(Array)
#1 /home/shahar/development/myfinalproject/lib/Cake/Console/Command/Task/ModelTask.php(900): ConnectionManager::getDataSource('default')
#2 /home/shahar/development/myfinalproject/lib/Cake/Console/Command/Task/ModelTask.php(837): ModelTask->getAllTables(NULL)
#3 /home/shahar/development/myfinalproject/lib/Cake/Console/Command/Task/ModelTask.php(926): ModelTask->listAll(NULL)
#4 /home/shahar/development/myfinalproject/lib/Cake/Console/Command/Task/ModelTask.php(205): ModelTask->getName()
#5 /home/shahar/development/myfinalproject/lib/Cake/Console/Command/Task/ModelTask.php(93): ModelTask->_interactive()
#6 /home/shahar/development/myfinalproject/lib/Cake/Console/Command/BakeShell.php(108): ModelTask->execute()
#7 /home/shahar/development/myfinalproject/lib/Cake/Console/Shell.php(392): BakeShell->main()
#8 /home/shahar/development/myfinalproject/lib/Cake/Console/ShellDispatcher.php(200): Shell->runCommand(NULL, Array)
#9 /home/shahar/development/myfinalproject/lib/Cake/Console/ShellDispatcher.php(68): ShellDispatcher->dispatch()
#10 /home/shahar/development/myfinalproject/app/Console/cake.php(37): ShellDispatcher::run(Array)
#11 {main}
我试图从我的应用程序目录运行 bake 命令(虽然我看到路径没问题),但我得到了同样的错误。我改变了我database.php
的localhost
to127.0.0.1
并且仍然发生同样的错误。
我在这里想念什么?
编辑:由于人们建议我检查 PDO 扩展的可用性,我做了一个小测试。我用了:
vagrant@precise64:/etc/php5/cli$ php -i | grep -i pdo
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini,
PDO
PDO support => enabled
PDO drivers => mysql
pdo_mysql
PDO Driver for MySQL => enabled
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock