简体   繁体   中英

could not find driver in laravel 7 application

I am trying to connect the database with my Laravel 7 application but each time when I hit php artisan migrate I am getting the following errors.

I have connected my.env file as below:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=""

Illuminate\Database\QueryException

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

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
    667|         // If an exception occurs when attempting to run a query, we'll format the error
    668|         // message to include the bindings with SQL, which will make this exception a
    669|         // lot more helpful to the developer instead of just the database's errors.
    670|         catch (Exception $e) {
  > 671|             throw new QueryException(
    672|                 $query, $this->prepareBindings($bindings), $e
    673|             );
    674|         }
    675| 

      +32 vendor frames 
  33  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

I have tried several ways including uncommenting an extension in the php.ini file but nothing changed!

Are you on Linux? If yes you'll have to install the php-mysql package if you're on Ubuntu and php-mysqlnd package if you're on Fedora.

On Windows and macOS all these stuff come built into WAMP or MAMP or whatever one uses.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM