【发布时间】:2019-09-17 10:45:32
【问题描述】:
我正在尝试运行我的 Laravel 5.7 应用,但在尝试在我的页面中运行查询时总是会收到错误 Could not find driver。
这是我的 .env 代码的一部分:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
无论如何,我们不使用 mysql,而是使用 MariaDB。我可以确认 mariadb 运行没有任何问题,因为如果我在终端中运行 mysql -u root -p,我可以连接到我的 MariaDB。这是我成功登录 MariaDB 后的欢迎信息。
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 44
Server version: 10.2.8-MariaDB MariaDB Server
运行 phpinfo() 将返回:
PDO support enabled
PDO drivers pgsql, sqlite
MySQL driver for PDO George Schlossnagle, Wez Furlong, Ilia Alshanetsky, Johannes Schlueter
MySQLi Zak Greant, Georg Richter, Andrey Hristov, Ulf Wendel
MySQLnd Andrey Hristov, Ulf Wendel, Georg Richter, Johannes Schlüter
但我可以确认我的/opt/rh/rh-php71/root/usr/lib64/php/modules 文件夹包含pdo_mysql.so、pdo.so、mysqli.so 和mysqlnd.so
我的/etc/opt/rh/rh-php71/php.d 文件夹也包含30-pdo_mysql.ini,其中仅包含一行extension=pdo_mysql.so
那么为什么我的 pdo mysql 没有运行呢?
【问题讨论】:
-
phpinfo()行PDO drivers pgsql, sqlite行实际上并未将 mysql 列为驱动程序。也许您必须重新启动 apache 或 nginx(或您正在使用的任何东西)? -
您可能会检查 selinux 没有阻止驱动程序或 ini 文件。
-
@ourmandave 是的,我很困惑为什么 PDO 驱动程序没有列出 mysql。我已经多次重启apache。如何检查 selinux 没有阻止驱动程序或 ini 文件?
标签: mysql laravel pdo mariadb rhel