php 为什么 Doctrine 说找不到 PDO 驱动程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7451945/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why does Doctrine say it can't find the PDO driver?
提问by Marc-Fran?ois
I tried Symfony 2 today and I tried to play a bit with Doctrine.
我今天尝试了 Symfony 2,并尝试使用 Doctrine。
But when I use the command php app/console doctrine:schema:create
in the command line, it returns this error:
但是当我php app/console doctrine:schema:create
在命令行中使用该命令时,它返回此错误:
[PDOException]
could not find driver
doctrine:schema:create [--dump-sql] [--em[="..."]]
My php.ini file and phpinfo() cleary show that the PDO driver is loaded. I also created a little script in pure PHP to connect to my database using PDO and it worked fine. No error, so PDO is well installed and works.
我的 php.ini 文件和 phpinfo() 清楚地显示 PDO 驱动程序已加载。我还在纯 PHP 中创建了一个小脚本来使用 PDO 连接到我的数据库,并且运行良好。没有错误,所以 PDO 安装良好并且工作正常。
PHP and MySQL are running on my computer using the last version of EasyPHP.
PHP 和 MySQL 正在我的计算机上使用最新版本的 EasyPHP 运行。
What could have gone wrong with Doctrine? Where should I look now?
Doctrine 可能出了什么问题?我现在应该去哪里看?
采纳答案by Ramy Deeb
回答by Simon East
Yeah, if you type php -m
at the command line, it should list both PDO
and pdo_mysql
. In my case it showed only PDO
which is why it could not find the MySQL driver.
是的,如果你php -m
在命令行输入,它应该同时列出PDO
和pdo_mysql
。在我的情况下,它只显示了PDO
为什么它找不到 MySQL 驱动程序。
As you've already commented, I think it's because the PHP CLI cannot find a suitable php.ini
file.
正如您已经评论过的,我认为这是因为 PHP CLI 找不到合适的php.ini
文件。
回答by kalibbala
sudo apt-get install php5-mysql
须藤 apt-get 安装 php5-mysql
will do the magic
会变魔术
回答by Tareq
On command line, check if you have PDO support:
在命令行上,检查您是否有 PDO 支持:
php -m|grep -i pdo
If not, search for php mysql support (Ubuntu):
如果没有,搜索 php mysql support (Ubuntu):
apt-cache search php5*|grep mysql
And install it:
并安装它:
sudo apt-get install php5-mysql
After installing the packagem check again, you should see the PDO mysql support.
再次安装 packagem 检查后,您应该会看到 PDO mysql 支持。
回答by Mihai Asandulesei
In my case, I've tried to run bin/console from a local terminal and not from the docker container.
就我而言,我尝试从本地终端而不是从 docker 容器运行 bin/console。
Maybe it will help the others!
也许它会帮助其他人!