1

I'm trying to run a migration following this tutorial https://www.youtube.com/watch?v=074AQVmvvdg&list=PL4cUxeGkcC9hL6aCFKyagrT1RCfVN4w2Q&index=13

I think the tutorial might be out of date because when I enter php artisan migrate; I get this error:

 Illuminate\Database\QueryException 

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

  at C:\Users\jonke\Documents\laravel\pizzahouse\vendor\laravel\framework\src\Illuminate\Database\Connection.php:703        
    699▕         // If an exception occurs when attempting to 
run a query, we'll format the error
    700▕         // message to include the bindings with SQL, 
which will make this exception a
    701▕         // lot more helpful to the developer instead 
of just the database's errors.
    702▕         catch (Exception $e) {
  ➜ 703▕             throw new QueryException(
    704▕                 $query, $this->prepareBindings($bindings), $e
    705▕             );
    706▕         }
    707▕     }

  1   C:\Users\jonke\Documents\laravel\pizzahouse\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDOException::("could not find driver")

  2   C:\Users\jonke\Documents\laravel\pizzahouse\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDO::__construct()

I've read the comments on the video, where I found the solution to an earlier error. I've tried following suggestion on this page: https://github.com/laravel/framework/issues/24711 which seemed promising but no joy.

I found pages on this website describing the same error message with different causes. One looked promising but vscode didn't like the sudo apt-get bits. (I've lost the link, sorry).

This one had a similar title but was no good: Migration in Laravel 5.6 - could not find driver

I also tried following the official docs: https://laravel.com/docs/8.x/migrations

How am I able to create the DB in the command line in vscode but not run the migration? I don't get it! I've been clicking around in circles for a couple of days now, can someone help me please?

Thanks

  • The error is saying you don't have the pdo_mysql extension installed (if this is about mysql) – apokryfos Oct 16 '21 at 11:09
  • It is about MySQL, following your suggestion I've been trying to find out how to install pdo_mysql but can't find it, do you have any suggestions please? –  Oct 16 '21 at 11:32
  • On windows you usually can just uncomment the relevant line in your `php.ini`. In certain linux distributions you can do `apt-get install php-pdo-mysql` – apokryfos Oct 16 '21 at 11:49

3 Answers3

1

It was the c:\php7/php.ini - needed to modify a line - uncomment this line:

extension=pdo_mysql

Answer found here: https://stackoverflow.com/a/25137901/16714187

Pawel Veselov
  • 3,996
  • 7
  • 44
  • 62
0

Added JonKemm Solution

It was the c:\php7/php.ini - needed to modify a line - uncomment this line: extension=pdo_mysql Answer found here: https://stackoverflow.com/a/25137901/16714187

If any other case your problem not solve try further

You have to add driver connection reading code. You can find in

config->database.php

'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

If you didn't find this in b/w

'connections' => [
...
],

Above version copied from Laravel Framework 6.20.30

If you missing something from these code from older laravel version try to compare or add some codes.

If you didn't find mysql code there Copy my code and paste into your file, If you find any error comment below.

Ronny Dsouza
  • 358
  • 2
  • 12
0

Answer :- Create laravel project in side file C:\xampp\htdocs because MySQL serve is for XAMPP Control Panel

Mr.V
  • 1
  • 1