Monday, March 20, 2017

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

I have a Laravel 5.4 project on my Ubuntu 14.04 (VPS with Plesk 12.5.30). After creating the database and setted up the .env file with required information I ran php artisan migrate and exceptions were thrown:

[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

I've followed most of the guides to solve this error and there wasn't any positive results:

Enabling Extension Solution:

PDO is enabled

The php.ini file is being generated automatically, I guess this is made by Plesk. At the start of the file it says:

; ATTENTION!
;
; DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
; SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

So I've tried it anyway. After that I've restarted Apache and then tried again... Didn't work.

Installing php7.0-mysql Solution:

I've also tried to install MySQL in case is not:

user@server:/var/www/vhosts$ sudo apt-get install php7.0-mysql

Leyendo lista de paquetes... Hecho

Creando árbol de dependencias

Leyendo la información de estado... Hecho

php7.0-mysql is already the newest version.

0 actualizados, 0 se instalarán, 0 para eliminar y 67 no actualizados.

user@server:/var/www/vhosts$

Composer Dump-autoload Solution:

It didn't work either. I've tried composer dump-autoload and it didn't work.



via Maramal

Advertisement