2

As soon, i press Enter 'php artisan migrate' command on ubuntu terminal. Error coming like:- [PDOException] Could Not Find Driver

I'm not able to fix this problem as i'm new to it.

Please help me to fix this issue.

enter image description here enter image description here

Nana Partykar
  • 10,556
  • 10
  • 48
  • 77
  • 1
    [Have a look at this](https://www.google.ro/search?client=ubuntu&channel=fs&q=[PDOException]+Could+Not+Find+Driver&ie=utf-8&oe=utf-8&gws_rd=cr&ei=mKbpVYftI4X9UIj7tcgL) – Andrei Sep 04 '15 at 14:12
  • Do you have seperated php configurations for your CLI? Maybe the modules are not loaded in CLI only – Sander Visser Sep 07 '15 at 15:15
  • `php -i | grep php.ini` should return which php.ini file is used. – Sander Visser Sep 07 '15 at 15:16

3 Answers3

1

Yo should be enable the PDO extension for you Database Manager in you php.ini

;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll //In my Case the extension enable is for pgsql
;extension=php_pdo_sqlite.dll

For enable you should delete the ; char in the line of the extension restart the server and voila

Pastor Durán A.
  • 364
  • 1
  • 12
-1

I made changes in "Project-Folder-Name/config/database.php". And, it worked. Added 'unix_socket' => '/opt/lampp/var/mysql/mysql.sock',

'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'DatabaseName'),
            'username'  => env('DB_USERNAME', 'root'),
            'password'  => env('DB_PASSWORD', ''),
        'unix_socket'   => '/opt/lampp/var/mysql/mysql.sock', //Your sock got from above
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],
Nana Partykar
  • 10,556
  • 10
  • 48
  • 77
  • This isn't the right solutions, because /opt/lampp/var/mysql/mysql.sock is far from the default configuration and it will break your application on other environments/systems. – Sander Visser Sep 07 '15 at 15:51
-1

I think you have a seperated configuration file (php.ini) for your CLI.

Try to execute php -i | grep php.ini in your console. And enable the required modules in that file.

It should return something like this:

sander@sander-Laptop:~$ php -i | grep php.ini
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini

As you can see it uses another php.ini file then what the phpinfo(); returns

Open that file and enable the required extensions there

so change the lines of the extensions that you require: ;extension=extension.so to extension=extension.so

Also a tip: If you use Laravel you can use the Homestead (vagrant, virtualbox) which is an virtual machine complete preinstalled for you laravel application

http://laravel.com/docs/5.1/homestead

Sander Visser
  • 4,144
  • 1
  • 31
  • 42