Summer Sale! All accounts are 50% off this week.

afoysal's avatar

could not find driver error in Laravel 5.5

I am facing below error while I am trying to run php artisan db:seed. I ran composer update and composer dump-autoload before.

enter image description here

0 likes
19 replies
TheMY3's avatar

Looks like you set wrong config in config/database.php file .

Check your config/database.php file with chosen connection and check driver value, or write it here.

afoysal's avatar

Thanks @TheMY3 for your reply. Here is my congin/database.php file.

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once using the Database library.
    |
    */

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

    /*
    |--------------------------------------------------------------------------
    | Database Connections
    |--------------------------------------------------------------------------
    |
    | Here are each of the database connections setup for your application.
    | Of course, examples of configuring each database platform that is
    | supported by Laravel is shown below to make development simple.
    |
    |
    | All database work in Laravel is done through the PHP PDO facilities
    | so make sure you have the driver for your particular database of
    | choice installed on your machine before you begin development.
    |
    */

    'connections' => [

        'sqlite' => [
            'driver' => 'sqlite',
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
        ],

        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'mylaravelvue'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', 'root'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

        'pgsql' => [
            'driver' => 'pgsql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

        'sqlsrv' => [
            'driver' => 'sqlsrv',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven't actually been run in the database.
    |
    */

    'migrations' => 'migrations',

    /*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer set of commands than a typical key-value systems
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */

    'redis' => [

        'client' => 'predis',

        'default' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
        ],

    ],

];

afoysal's avatar

Thanks @TheMY3 for your reply. Here is my .env file.

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:IvytBNFzkpRaLJ3O29/Z95HI5qnDmKx7YCoeNQiTnh4=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

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

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=

afoysal's avatar

Thanks @kobear for your reply. I am using Linux Mint. I installed MySql using this command

sudo apt-get install mysql-server php7.0-mysql phpmyadmin 

Thanks

kobear's avatar

Did you enable php_mysqli in the php.ini file?

Look for this line in php.ini file and make sure it is uncommented

extension=php_mysqli.so
afoysal's avatar

Thanks @kobear for your help. There is no extension=php_mysqli.so line in my php.ini file. I found extension=php_mysqli.dll in my php.ini file and uncomment it. Restart server and run php artisan db:seed and got same result as before.

kobear's avatar

can you please post the output of the following command?

php -m | grep mysql
kobear's avatar

@afoysal MySQL support did not get installed with PHP.

Try running the following command

sudo apt-get install php-mysql

Then restart apache and try again.

mcangueiro's avatar

What is the output of the following command

php -m
kobear's avatar

What is the output of running the php-mysql install command?

mcangueiro's avatar
Level 3

Assuming you are running on PHP 7.1 you could try installing mysql with this command

sudo apt-get install php7.1-mysql
5 likes
ndotie's avatar

@mcangueiro Works for me as well but i adjusted to latest php version sudo apt-get install php8.1-mysql

HashmatWaziri's avatar

Using Laravel V 5.5.39 with Php 7.1.12 is working fine, but later (newer) php versions causes the problem. So, change Php version and you will get the solution 100% .

Please or to participate in this conversation.