首页  >  文章  >  数据库  >  PHP 7.0 上的 Laravel 5.4:为什么我会收到“无法找到驱动程序 (MySQL)”PDO 异常?

PHP 7.0 上的 Laravel 5.4:为什么我会收到“无法找到驱动程序 (MySQL)”PDO 异常?

DDD
DDD原创
2024-11-14 17:01:02746浏览

Laravel 5.4 on PHP 7.0: Why Am I Getting a

Laravel 5.4 on PHP 7.0: Resolving "Could not find driver (MySQL)" PDO Exception

Issue Overview

When attempting to migrate a database using Laravel 5.4 on Ubuntu 14.04 with Plesk 12.5.30 and PHP 7.0, the following exceptions are encountered:

  • [Illuminate\Database\QueryException]

    • could not find driver (SQL: select * from information_schema.tables where table_schema = pmaramaldb and table_name = migrations)
  • [PDOException]

    • could not find driver

Troubleshooting

The following solutions have been attempted without success:

  • Enabling PDO Extension:

    • PDO is already enabled.
  • Installing php7.0-mysql:

    • PHP 7.0-mysql is already installed.
  • Installing php5-sqlite:

    • PHP 5.5-sqlite is already installed.
  • Running composer dump-autoload:

    • Has no effect.

Alternative Solution

Ensure that php7-mysql is installed. Run the following command:

sudo apt install php7.0-mysql

If Automatic Installation is Preferred:

sudo apt install php-mysql

This should resolve the "could not find driver (MySQL)" PDO exception in Laravel 5.4 with PHP 7.0.

以上是PHP 7.0 上的 Laravel 5.4:为什么我会收到“无法找到驱动程序 (MySQL)”PDO 异常?的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn