问题描述
我正在用 Symfony 制作我的第一个应用程序,当我设置我的数据库时(不管是 postgresql 还是 mysql).
I am making my first app with Symfony and when i setup my database (doesn't matter if it's postgresql or mysql).
我有一个错误找不到驱动程序"三次.PDOConnection.php 第 38 行中的一个.
I have an error "could not find driver" three time.One in PDOConnection.php line 38.
Exception.php 第 18 行中的其他.
Other in Exception.php line 18.
最后一个在 AbstractMySQLDriver.php 第 128 行.
And last one in AbstractMySQLDriver.php line 128.
我做了什么:我检查了 php 路径,我还检查了所有扩展名.我检查我是否正确填写了 .env 并检查了这些文件夹.
What i made : i check the php path i also check all the extensions. I check if i fill correctly .env and i check those folders.
PHP 版本:7.4
和 docker 容器中的 mysql:mysql:5.7.
And mysql in docker containers: mysql:5.7.
我现在真的不知道该怎么办
I really have no idea what to do now
更新:
问题(对我来说)是命令 php bin/console algorithm:database:create
The problem (for me) was the command php bin/console doctrine:database:create
如果你有同样的问题,试试 symfony police:database:create
if you have the same problem try symfony doctrine:database:create
推荐答案
你使用 .env 文件吗?我有同样的问题,在禁用/启用 pdo 一天后没有任何效果,我发现 symfony 自动在我的 .env 文件中添加了一行:
do you use .env file? I have same problem and after a day of disable/enable pdo without any effect, i found that symfony auto add a line to my .env file:
DATABASE_URL=postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8
由于 postgresql 而不是 mysql,这使我的数据库 url 错误并且未找到错误 pdo fire
That make my database url wrong and error not found pdo fire because of postgresql not mysql
这篇关于Symfony 5 异常找不到驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!