Laravel: 错误 [PDOException]: 在 PostgreSQL 中找不到驱动程序
P粉722409996
P粉722409996 2023-07-31 18:16:43
[PHP讨论组]

Translate: "我正在尝试通过Laravel连接到PostgreSQL数据库,以便执行php artisan migrate命令,但似乎没有成功,因为它正在读取MySQL的数据库名称。

以下是database.php中的命令:


'connections' => array(

    'sqlite' => array(
        'driver'   => 'sqlite',
        'database' => __DIR__.'/../database/production.sqlite',
        'prefix'   => '',
    ),

    'mysql' => array(
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'database',
        'username'  => 'root',
        'password'  => '',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
    ),

    'pgsql' => array(
        'driver'   => 'pgsql',
        'host'     => 'localhost',
        'database' => 'postgres',
        'username' => 'postgres',
        'password' => 'root',
        'charset'  => 'utf8',
        'prefix'   => '',
        'schema'   => 'public',
    ),

    'sqlsrv' => array(
        'driver'   => 'sqlsrv',
        'host'     => 'localhost',
        'database' => 'database',
        'username' => 'root',
        'password' => '',
        'prefix'   => '',
    ),

),

如果我删除MySQL的路径,我会得到:

[InvalidArgumentException]
Database [mysql] not configured.



Translate: "编辑:当尝试执行 php artisan migrate 命令时,我遇到了 'PDOException: could not find driver' 错误。我正在使用 WAMP 并且在 Windows 8.1 上。数据库使用的是 PostgreSQL。"




EDIT: Translate: "我已经尝试了一系列的替代解决方案,但问题仍未解决。已经检查了 Apache、WAMP(来自 php 文件夹)和 PostgreSQL 中的 php.ini 文件。extension_dir 设置正确,如下所示 -> extension_dir = "c:/wamp/bin/php/php5.5.12/ext/"。extension=pdo_pgsql.dll 和 extension=pgsql.dll 已经被取消注释。

已经在 '系统变量' 中进行了 PATH 的设置,并重新启动了计算机。但是仍然没有成功。

感谢迄今为止的帮助。

这是我的驱动程序 php_pdo_driver.h 和 php_pdo.h 位于 C:Program Files (x86)PostgreSQLEnterpriseDB-ApachePHPphpSDKincludeextpdo

从 phpinfo 中获取的信息:


Translate: "PHP 版本 5.5.12

编译器 MSVC11 (Visual C++ 2012) 配置命令 cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:php-sdkoraclex64instantclient10sdk,shared" "--with-oci8=C:php-sdkoraclex64instantclient10sdk,shared" "--with-oci8-11g=C:php-sdkoraclex64instantclient11sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo""



P粉722409996
P粉722409996

全部回复(1)
P粉043295337

"对于 PDOException: could not find driver for MySQL 错误,如果是基于 Debian 的操作系统

sudo apt-get -y install php5-mysql
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号