Search code examples
laravellaravel-5artisan-migrate

Laravel 5.5 unable to do initial migrate


I am trying to do the initial migration on a fresh laravel 5.5 installation. The home page works, but I seem to have a db setup issue. I'm using MariaDB and I am able to connect to my DB with a separate db client with no issues. Also I'm able to echo the DB name to the welcome screen without issue. Error is below:

[Illuminate\Database\QueryException] could not find driver (SQL: select * from information_schema.tables where table_schema = TestApp and table_name = migrations)

[PDOException] could not find driver

welcome.blade.php code that works:

@if(DB::connection()->getDatabaseName()) <p>Database: {{ DB::connection()->getDatabaseName() }}</p> @endif

database.php

'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', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],

.env file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=TestApp
DB_USERNAME=ubuntu
DB_PASSWORD=secret

Solution

  • May be you need to install PHPs PDO MySQL support to your server/dev machine.

    Look at your phpinfo() for PDO MySQL driver info. IF doesnt exists install the driver.

    If your server/dev-machine is ubuntu and your php version is 7.0 try to install with apt-get install like this

    sudo apt-get install php7.0-mysql
    

    You can use the MySQL PDO driver with a MariaDB database