0

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
Billy Joe
  • 49
  • 1
  • 8

1 Answers1

1

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

Edgar Orozco
  • 2,722
  • 29
  • 33
  • I just updated the post with more info. "Also I'm able to echo the DB name to the welcome screen without issue." – Billy Joe Feb 19 '18 at 22:52
  • then you have properly installed the PDO MySql driver? If not, that is the problem to solve. – Edgar Orozco Feb 19 '18 at 23:39
  • I was guessing that the driver is installed properly because my app is connecting to the DB when I hit the homepage. But maybe that doesn't guarantee the migrations will also work? When I echo out phpinfo(), for the mysql part I get `MySQL driver for PDO George Schlossnagle, Wez Furlong, Ilia Alshanetsky, Johannes Schlueter` – Billy Joe Feb 20 '18 at 00:14
  • 1
    Thanks, ended up seeing that my comment above was wrong, the PDO driver wasn't installed. – Billy Joe Feb 20 '18 at 03:19