【问题标题】:PDO Driver not found when execute command执行命令时找不到 PDO 驱动程序
【发布时间】:2022-10-21 21:52:56
【问题描述】:

我的数据库遇到问题。上下文:Web 应用程序引用成员,可以通过 xls 文件存储库导入成员,并进行处理以将其保存在数据库中。我尝试执行一个应该在生产环境的后台运行的命令,但在开发环境中它必须手动执行,以执行具有“要导入”状态的文件的导入。执行过程中出现问题,命令显示PDO有驱动问题,找不到。 知道问题可能来自哪里吗? 你会在这里找到详细的错误信息,以及 symfony 5 项目的 config.yml

In AbstractMySQLDriver.php line 128:
                                                          
  An exception occurred in driver: could not find driver  
                                                          

In Exception.php line 18:
                         
  could not find driver  
                         

In PDOConnection.php line 40:
                         
  could not find driver  
                         
doctrine:
    dbal:
        driver: pdo_mysql
        host: '%database_host%'
        port: '%database_port%'
        dbname: '%database_name%'
        user: '%database_user%'
        password: '%database_password%'
        charset: UTF8
        types:
            phone_number: Misd\PhoneNumberBundle\Doctrine\DBAL\Types\PhoneNumberType
        server_version: "%doctrine_server_version%"
        options:
            1002: 'SET sql_mode=(SELECT REPLACE(@@sql_mode, "ONLY_FULL_GROUP_BY", ""))'

    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true
        dql:
            string_functions:
                MONTH: DoctrineExtensions\Query\Mysql\Month
                YEAR: DoctrineExtensions\Query\Mysql\Year
                regexp: DoctrineExtensions\Query\Mysql\Regexp
                replace: DoctrineExtensions\Query\Mysql\Replace
                DATE_FORMAT: DoctrineExtensions\Query\Mysql\DateFormat
        mappings:
            gedmo_tree:
                type: annotation
                prefix: Gedmo\Tree\Entity
                dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
                alias: GedmoTree # (optional) it will default to the name set for the mapping
                is_bundle: false

【问题讨论】:

  • 你能告诉我们你的 .env 文件吗?

标签: database symfony orm


【解决方案1】:

检查 .env 文件上的 DATABASE_URL 主机是否正确。 你应该有类似DATABASE_URL=mysql://dbuser:dbpassword@127.0.0.1:3306/something

如果设置正确,请检查您的本地安装(通常使用sudo apt-get install pdo-mysql)

如果extension=pdo_mysql 没有被注释,还要检查你的 php.ini 文件。

【讨论】:

    猜你喜欢
    • 2016-08-05
    • 2017-11-07
    • 2019-06-27
    • 1970-01-01
    • 2014-07-23
    • 2013-04-25
    • 2017-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多