sql - Symfony 5 - “驱动程序发生异常:找不到驱动程序”
问题描述
我目前面临这个问题。我是 Symfony 的新手。
问题:当我使用 cli 创建新数据库symfony console doctrine:database:create
时,出现以下错误:
In AbstractPostgreSQLDriver.php line 102:
An exception occurred in driver: could not find driver
In Exception.php line 18:
could not find driver
In PDOConnection.php line 38:
could not find driver
我正在使用带有 xampp 的 php 7.4 并且安装了正常的 pdo_sql :
extension=bz2
extension=curl
;extension=ffi
;extension=ftp
extension=fileinfo
extension=gd2
extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=ldap
extension=mbstring
extension=exif ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
;extension=odbc
extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql
extension=pdo_sqlite
;extension=pgsql
;extension=shmop
这是我的 .env 文件配置:
###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
DATABASE_URL="mysql://root:@127.0.0.1:3306/dbname"
DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###
这是我的教义.yaml 文件配置:
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '13'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
我一直在寻找几个小时,但我无法找到任何解决方案来解决我的问题,有人有想法吗?我在窗户上。
非常感谢 !
解决方案
如果你想使用 Mysql ,注释这一行DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
如果不注释另一行
推荐阅读
- ruby - 替换与特定正则表达式不匹配的字符
- python - 运行pytorch时如何加载cuda?
- node.js - 处理每条 Express 路线上的异常情况
- javascript - 一旦所有字段都输入正确,如何使用 javascript 启用“创建帐户”按钮?
- python - 在 Sqlalchemy 中查询格式不正确以进行选择
- angular - 从外部 IP 连接到 Angular 和 springboot 应用程序
- javascript - 当我在 React 上滚动时如何移动按钮?
- java - Android:与相同模型的 Python 相比,TFLite 给出了错误的预测
- java - SpringBoot 白页
- winapi - 如何使用 win32 Visual C++ 检测 CD 是否在 CD ROM 托盘中