vendredi 3 janvier 2020

Cannot fix PDOException::(“could not find driver”) on Laravel migration. At wit's end after having tried all solutions suggested in similar questions

Here's a list of stuff I've done in order to attempt to fix the issue:

I'm on Windows 7 and using MAMP. My PHP version is 7.3.7.

The full error I'm getting is:

Illuminate\Database\QueryException  : could not find driver (SQL: select * from information_schema.tables where table_schema = lol and table_name = migrations and table_type = 'BASE TABLE')

  at C:\MAMP\htdocs\League Of Legends Backend\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e

    666|             );
    667|         }
    668|

  Exception trace:

  1   Doctrine\DBAL\Driver\PDOException::("could not find driver")
      C:\MAMP\htdocs\League Of Legends Backend\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:31

  2   PDOException::("could not find driver")
      C:\MAMP\htdocs\League Of Legends Backend\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:27

  Please use the argument -v to see more details.

Used phpinfo() on one of the pages served by the server in order to determine PHP version and location of php.ini file. My PHP version is 7.3.7 and my php.ini file is located at C:\MAMP\conf\php7.3.7\php.ini. These 3 lines are uncommented in that file:

extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll

Used get_loaded_extensions on one of the pages served by the server in order to see all loaded extensions. This is the list:

array:45 [▼
  0 => "Core"
  1 => "bcmath"
  2 => "calendar"
  3 => "com_dotnet"
  4 => "ctype"
  5 => "date"
  6 => "filter"
  7 => "hash"
  8 => "iconv"
  9 => "json"
  10 => "SPL"
  11 => "odbc"
  12 => "pcre"
  13 => "Reflection"
  14 => "session"
  15 => "sockets"
  16 => "standard"
  17 => "mysqlnd"
  18 => "tokenizer"
  19 => "zip"
  20 => "zlib"
  21 => "libxml"
  22 => "dom"
  23 => "PDO"
  24 => "bz2"
  25 => "SimpleXML"
  26 => "soap"
  27 => "xml"
  28 => "wddx"
  29 => "xmlreader"
  30 => "xmlwriter"
  31 => "apache2handler"
  32 => "openssl"
  33 => "gd"
  34 => "gettext"
  35 => "mbstring"
  36 => "exif"
  37 => "mysqli"
  38 => "pdo_sqlite"
  39 => "sqlite3"
  40 => "curl"
  41 => "Phar"
  42 => "imagick"
  43 => "pdo_mysql"
  44 => "fileinfo"
]

In Laravel's database.php file, MySQL is set as default:

'default' => env('DB_CONNECTION', 'mysql'),

I tried using composer update and composer dump-autoload too.

My database env variables are set correctly. I can interact with my database by inserting, deleting, updating and selecting, however, I cannot migrate for some reason:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=lol
DB_USERNAME=root
DB_PASSWORD=root

I've read through all similar questions here and I'm out of options now. I've run out of things to try out so I'd appreciate any help.



via Chebli Mohamed

1 commentaire:

  1. add extension=php_pdo_mysql.dll to your C:/xampp/php.ini and also C:/php/php.ini

    RépondreSupprimer