PHP Artisan Migrate Throwing [Pdo Exception] Could Not Find Driver - Using Laravel

php artisan migrate throwing [PDO Exception] Could not find driver - Using Laravel

You can use

sudo apt-get install php7-mysql

or

sudo apt-get install php5-mysql

or

sudo apt-get install php-mysql

This worked for me.

Laravel: PDOException: could not find driver

You might need to comment out the following in your php.ini file.

;extension=pdo_mysql.so

Taken from this post:
Laravel 5 PDOException Could Not Find Driver
. I think I had to do something exactly like this when setting up laravel on digital ocean.

Laravel migration error - could not find driver - Illuminate\Database\QueryException

Added JonKemm Solution

It was the c:\php7/php.ini - needed to modify a line - uncomment this line: extension=pdo_mysql Answer found here: https://stackoverflow.com/a/25137901/16714187

If any other case your problem not solve try further

You have to add driver connection reading code. You can find in

config->database.php

'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'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' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],

Laravel 5.4 on PHP 7.0: PDO Exception - Could not find driver (MySQL)

There's a conflict between the PHP that is used by Apache and the PHP that is linked to the command line. (It happens more often that it should to be honest).

What is typically done is:

which php

This tells you which php will be expecuted when running in the command line. e.g. /usr/bin/php

mv /usr/bin/php /usr/bin/php.old

Then link or copy the correct PHP version to an executable path:

ln -s /path/to/php/bin/php /usr/bin/php

or the following should also work.

cp /path/to/php/bin/php /usr/bin/php

Also suggested if you want to be able to manually install mods:

ln -s /path/to/php/bin/phpize /usr/bin/phpize
ln -s /path/to/php/bin/php-config /usr/bin/php-config

This way your CLI will match your webserver.

Update:

If as noted in this answer if you are using Ubuntu with multiple alternative installations of PHP you can do:

sudo update-alternatives --set php /usr/bin/php<version>
sudo update-alternatives --set phar /usr/bin/phar<version>
sudo update-alternatives --set phar.phar /usr/bin/phar.phar<version>
sudo update-alternatives --set phpize /usr/bin/phpize<version>
sudo update-alternatives --set php-config /usr/bin/php-config<version>

Laravel migration error using XAMPP: [PDOException] could not find driver

This can happen for a Number of reasons.
Either the Default DB type is not set (config/database.php),
or the Extension is not enabled,
or you HAVE enabled the extension but have NOT restarted XAMPP,
or the PATH settings under environment settings are not properly defined.

I suggest you check out this answer which may solve the issue: https://stackoverflow.com/a/25336292/2745485

Regards.

PDOException “could not find driver”

You need to have a module called pdo_mysql. Looking for following in phpinfo(),

pdo_mysql

PDO Driver for MySQL, client library version => 5.1.44


Related Topics



Leave a reply



Submit